Hi.
I may have rudely just sent a patch without explaining anything, I thought
the patch was self explanitory. I'm not sure on the expected procedure
here for sending patches.
When using "git rebase", when "diff.noprefix" is set to true in
git-config, then all the rebases mess up because they get the directory
path wrong.
As far as I can tell, my patch fixes this, with no side-effects that I can
think of.
Can anyone comment on the patch? Can it be pushed upstream?
- ods15
From: Jan Krüger <hidden> Date: 2016-06-15 22:49:31
Oded Shimon [off-list ref] wrote:
---
A shorter summary (subject) and more of a commit message body might be a
good idea. People tend to like patch summaries that fit into one line
on a terminal, and shorter is even better for those tools that output
additional fields on the same line.
Signoff is missing, please see Documentation/SubmittingPatches for
details (including the reason why we need one in the first place).
I can't comment on the patch itself since I'm not familiar with the
whole diff machinery nor the innards of rebase.
For the case of "diff.noprefix" in git-config, git-format-patch should
still output diff with standard prefixes for git-am
Signed-off-by: Oded Shimon <redacted>
---
git-rebase.sh | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
From: Thomas Rast <hidden> Date: 2016-06-15 22:49:31
format-patch read and used the diff UI config, such as diff.renames,
diff.noprefix and diff.mnemnoicprefix. These have a history of
breaking rebase and patch application in general; cf. 840b3ca (rebase:
protect against diff.renames configuration, 2008-11-10).
Instead of continually putting more options inside git-rebase to avoid
these issues, this patch takes the stance that output from
format-patch is intended primarily for git-am and only as a side
effect also for human consumption. Hence, ignore the diff UI config
entirely when coming from format-patch.
Note that all existing calls to git_log_config except for the one in
git_format_config use a NULL callback.
Reported-by: Oded Shimon <redacted>
Signed-off-by: Thomas Rast <redacted>
---
This is a bolder approach that just outright ignores the backwards
compatibility complaints Junio had in 840b3ca. Among the variables
parsed in git_diff_ui_config, namely
color.diff (and its legacy alias diff.color)
diff.renames
diff.autorefreshindex
diff.mnemonicprefix
diff.noprefix
diff.external
diff.wordregex
diff.ignoresubmodules
arguably only diff.renames (and perhaps diff.ignoresubmodules, I don't
use them) should affect format-patch. Everything else undermines the
guarantee (by having a consistent format) that format-patch|am works.
So now I'm not so sure about diff.renames. Perhaps it needs to be
retained, but that requires a special case since we cannot move it to
git_diff_basic_config() (which affects diff-* plumbing too).
In any case I also made a test. If you decide to go for the original
patch, please feel free to "steal" it.
builtin/log.c | 20 ++++++++++++++++++--
t/t3400-rebase.sh | 7 +++++++
2 files changed, 25 insertions(+), 2 deletions(-)
@@ -1099,6 +1113,7 @@ int cmd_format_patch(int argc, const char **argv, const char *prefix)char*add_signoff=NULL;structstrbufbuf=STRBUF_INIT;intuse_patch_format=0;+structlog_config_cb_dataconfig_cb_data;conststructoptionbuiltin_format_patch_options[]={{OPTION_CALLBACK,'n',"numbered",&numbered,NULL,"use [PATCH n/m] even with a single patch",
@@ -144,6 +144,13 @@ test_expect_success 'rebase is not broken by diff.renames' 'GIT_TRACE=1gitrebaseforce-3way'+test_expect_success'rebase is not broken by diff.noprefix''+gitconfigdiff.noprefixtrue&&+test_when_finished"git config --unset diff.noprefix"&&+gitcheckout-bnoprefixside&&+GIT_TRACE=1gitrebasemaster+'+ test_expect_success'setup: recover''test_might_failgitrebase--abort&&gitreset--hard&&
From: Jeff King <hidden> Date: 2016-06-15 22:49:31
On Thu, Sep 09, 2010 at 10:36:54AM +0200, Thomas Rast wrote:
format-patch read and used the diff UI config, such as diff.renames,
diff.noprefix and diff.mnemnoicprefix. These have a history of
breaking rebase and patch application in general; cf. 840b3ca (rebase:
protect against diff.renames configuration, 2008-11-10).
Instead of continually putting more options inside git-rebase to avoid
these issues, this patch takes the stance that output from
format-patch is intended primarily for git-am and only as a side
effect also for human consumption. Hence, ignore the diff UI config
entirely when coming from format-patch.
Note that all existing calls to git_log_config except for the one in
git_format_config use a NULL callback.
This was my first thought upon reading Oded's patch, too. We would want
to cut out anything that will cause format-patch to create a patch that
could not be applied. So from your list:
This is a bolder approach that just outright ignores the backwards
compatibility complaints Junio had in 840b3ca. Among the variables
parsed in git_diff_ui_config, namely
color.diff (and its legacy alias diff.color)
diff.renames
diff.autorefreshindex
diff.mnemonicprefix
diff.noprefix
diff.external
diff.wordregex
diff.ignoresubmodules
arguably only diff.renames (and perhaps diff.ignoresubmodules, I don't
use them) should affect format-patch. Everything else undermines the
guarantee (by having a consistent format) that format-patch|am works.
I would agree that diff.renames should probably be the only thing we
want to allow (because it is not about making a broken diff, but because
the receiver may or may not support it, and we already know that
git-rebase will handle it).
diff.external is debatable. If your external diff is producing real,
applicable diffs, then it is fine to use it. I have to wonder why you
would use an external diff, then. I guess because it's faster, or maybe
has an algorithm that produces equivalent but easier-to-read results
(e.g., patience before we had --patience)?
So now I'm not so sure about diff.renames. Perhaps it needs to be
retained, but that requires a special case since we cannot move it to
git_diff_basic_config() (which affects diff-* plumbing too).
I think it is reasonable to just move an explicit "diff.renames" check
into format_patch, and then set the diff_options appropriately. It
requires special case code because it _is_ a special case.
-Peff
From: Junio C Hamano <hidden> Date: 2016-06-15 22:49:31
Thomas Rast [off-list ref] writes:
...
arguably only diff.renames (and perhaps diff.ignoresubmodules, I don't
use them) should affect format-patch. Everything else undermines the
guarantee (by having a consistent format) that format-patch|am works.
We need to be a bit careful here.
Each user must be able to find a combination of ($opts1, $opts2) to make
"format-patch $opts1 | am $opts2" run correctly with his funny settings
(e.g. diff.noprefix). We must guarantee that [*1*].
I however don't think we need to guarantee that the pipeline always works
for empty opts1/2, and certainly we shouldn't insist what flows in that
pipe must be the bog-standard -p1 with a/ b/ prefix patch. For example,
in circles under svn influence, people may prefer opts1=--no-prefix, and
as long as the recipient understands that is the community norm around
there, he can run his "am" with -p0 and everything should work. It is not
unreasonable for the sender to have diff.noprefix in the repository config
in such a setup, don't you think?
There is no way to easily affect what options the "format-patch | am"
pipeline uses inside rebase. It may make sense to introduce --rebasing
option to format-patch to cause it to ignore any funny setting the user
might have, so that we don't have to keep adding options to the command
invocation. "am" has --rebasing already, and it may be beneficial to
teach the codepath to defeat some configuration variables in a similar
way.
[Footnote]
*1* ... within reason. For example, I don't think there is no opts2 if
you had opts1="--src-prefix=a/ --dst-prefix=b/c/" that makes the pipeline
work reasonably.