From: Bruno Haible Date: Sun, 17 Feb 2008 14:42:34 +0000 (+0100) Subject: Support the "git pull --rebase" situation. X-Git-Tag: v0.1~7743 X-Git-Url: http://erislabs.org.uk/gitweb/?a=commitdiff_plain;h=177498a108d49a4cfe37027ca5df0483adcb6ef0;p=gnulib.git Support the "git pull --rebase" situation. --- diff --git a/ChangeLog b/ChangeLog index 468a04f15..a5c084bd9 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2008-02-17 Bruno Haible + + * lib/git-merge-changelog.c: Include c-strstr.h. + (main): Support the "git pull --rebase" situation. + * modules/git-merge-changelog (Depends-on): Add c-strstr. + Reported by Eric Blake. + 2008-02-16 Eric Blake Avoid doubling \ in common case of "c-maybe" quoting style. diff --git a/lib/git-merge-changelog.c b/lib/git-merge-changelog.c index 98b6180de..4a63f94ac 100644 --- a/lib/git-merge-changelog.c +++ b/lib/git-merge-changelog.c @@ -67,10 +67,11 @@ being merged in. In case of a "git stash apply" or of an upstream pull (e.g. from a subsystem - maintainer to a central maintainer): + maintainer to a central maintainer) or of a downstream pull with --rebase: 2. %A = The file's newest pulled contents; modified by other committers. 3. %B = The user's newest copy of the file; modified by the user. - In case of a downstream pull (e.g. from a central repository to the user): + In case of a downstream pull (e.g. from a central repository to the user) + or of an upstream pull with --rebase: 2. %A = The user's newest copy of the file; modified by the user. 3. %B = The file's newest pulled contents; modified by other committers. @@ -137,6 +138,7 @@ #include "xmalloca.h" #include "fstrcmp.h" #include "minmax.h" +#include "c-strstr.h" #include "fwriteerror.h" #define ASSERT(expr) \ @@ -827,8 +829,9 @@ There is NO WARRANTY, to the extent permitted by law.\n\ "git pull" only to pull downstream. How to distinguish these situation? There are several hints: - - During a "git stash apply", GIT_REFLOG_ACTION is not set. During - a "git pull", it is set to 'pull '. + - During a "git stash apply", GIT_REFLOG_ACTION is not set. During + a "git pull", it is set to 'pull '. During a "git pull --rebase", + it is set to 'pull --rebase'. - During a "git stash apply", there is an environment variable of the form GITHEAD_<40_hex_digits>='Stashed changes'. */ { @@ -849,7 +852,8 @@ There is NO WARRANTY, to the extent permitted by law.\n\ printf ("GIT_REFLOG_ACTION=|%s|\n", var); #endif if (var != NULL - && (strncmp (var, "pull", 4) == 0 + && ((strncmp (var, "pull", 4) == 0 + && c_strstr (var, " --rebase") == NULL) || strncmp (var, "merge origin", 12) == 0)) downstream = true; else @@ -868,7 +872,10 @@ There is NO WARRANTY, to the extent permitted by law.\n\ sprintf (buf, "head -1 %s", destination_file_name); system (buf); printf ("First line of %%B:\n"); sprintf (buf, "head -1 %s", other_file_name); system (buf); - printf ("Guessing direction: %sstream\n", downstream ? "down" : "up"); + printf ("Guessing calling convention: %s\n", + downstream + ? "%A = modified by user, %B = upstream" + : "%A = upstream, %B = modified by user"); } #endif diff --git a/modules/git-merge-changelog b/modules/git-merge-changelog index ed3ee0ba8..6b3f9dcbe 100644 --- a/modules/git-merge-changelog +++ b/modules/git-merge-changelog @@ -18,6 +18,7 @@ xalloc xmalloca fstrcmp minmax +c-strstr fwriteerror configure.ac: