{"thread":{"id":"4839","subject":"git-update-ref (reflog) uses bogus author ident information","startedAt":"2006-07-10T20:52:32Z","lastAt":"2006-07-11T03:38:35Z","messageCount":6,"participants":["Jakub Narebski","Shawn Pearce"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"23581","messageId":"e8uele$o7t$2@sea.gmane.org","threadId":"4839","inReplyTo":null,"subject":"git-update-ref (reflog) uses bogus author ident information","fromName":"Jakub Narebski","fromEmail":"jnareb@gmail.com","sentAt":"2006-07-10T20:52:32Z","receivedAt":"2006-07-10T20:52:32Z","isPatch":false,"sender":{"key":"jnareb@gmail.com","avatar":"https://avatars.githubusercontent.com/u/2706?v=4"},"body":"git-log reports \n\n  commit 059111c9381ce1444d17c8fc35606b0aa417ca42\n  Author: Jakub Narebski <jnareb@gmail.com>\n  Date:   Sat Jul 8 18:52:35 2006 +0200\n  \n      configure.ac vertical whitespace usage cleanup\n \ngit-var -l shows:\n\n GIT_COMMITTER_IDENT=Jakub Narebski <jnareb@gmail.com> 1152564452 +0200\n GIT_AUTHOR_IDENT=Jakub Narebski <jnareb@gmail.com> 1152564452 +0200\n\nBUT in git/.git/logs/refs/heads/autoconf I have (broken into lines):\n  fe7b45a419ae62ed96148d98f6aba8710a6f6245\n  059111c9381ce1444d17c8fc35606b0aa417ca42 \n  Jakub Narebski <jnareb@roke.D-201> 1152377555 +0200   \n  commit: configure.ac vertical whitespace usage cleanu\n\nwhere \"roke.D-201\" are results of \"hostname -f\" on my computer, and are\nsuitable _only_ for my small private local network.\n\nBug or a feature?\n\nI use git 1.4.0.\n-- \nJakub Narebski\nWarsaw, Poland\nShadeHawk on #git\n"},{"id":"23589","messageId":"e8uhvg$5o1$2@sea.gmane.org","threadId":"4839","inReplyTo":"e8uele$o7t$2@sea.gmane.org","subject":"reflog doesn't note that commit was --amend-ed, and doesn't record pulls","fromName":"Jakub Narebski","fromEmail":"jnareb@gmail.com","sentAt":"2006-07-10T21:49:06Z","receivedAt":"2006-07-10T21:49:06Z","isPatch":false,"sender":{"key":"jnareb@gmail.com","avatar":"https://avatars.githubusercontent.com/u/2706?v=4"},"body":"Additionally, while reflog records git-reset invocations, it doesn't\ndistinguish between an ordinary commit, and commit --amend (which I do\na lot, most time because of forgotten update-index; yes, I know about commit\n-a option ;-). Well, you can extract this information looking at current\nand previous commit sha1, but it would be nice to have it noted somewhat in\nmessage part of reflog.\n\nReflog doesn't seem also to record pulls (e.g. master branch): pulls has\nempty reflog message part.\n\n-- \nJakub Narebski\nWarsaw, Poland\nShadeHawk on #git\n"},{"id":"23602","messageId":"20060711002754.GB10700@spearce.org","threadId":"4839","inReplyTo":"e8uele$o7t$2@sea.gmane.org","subject":"Re: git-update-ref (reflog) uses bogus author ident information","fromName":"Shawn Pearce","fromEmail":"spearce@spearce.org","sentAt":"2006-07-11T00:27:54Z","receivedAt":"2006-07-11T00:27:54Z","isPatch":false,"sender":{"key":"spearce@spearce.org","avatar":"https://avatars.githubusercontent.com/u/34844?v=4"},"body":"Jakub Narebski <jnareb@gmail.com> wrote:\n> git-log reports \n> \n>   commit 059111c9381ce1444d17c8fc35606b0aa417ca42\n>   Author: Jakub Narebski <jnareb@gmail.com>\n>   Date:   Sat Jul 8 18:52:35 2006 +0200\n>   \n>       configure.ac vertical whitespace usage cleanup\n>  \n> git-var -l shows:\n> \n>  GIT_COMMITTER_IDENT=Jakub Narebski <jnareb@gmail.com> 1152564452 +0200\n>  GIT_AUTHOR_IDENT=Jakub Narebski <jnareb@gmail.com> 1152564452 +0200\n> \n> BUT in git/.git/logs/refs/heads/autoconf I have (broken into lines):\n>   fe7b45a419ae62ed96148d98f6aba8710a6f6245\n>   059111c9381ce1444d17c8fc35606b0aa417ca42 \n>   Jakub Narebski <jnareb@roke.D-201> 1152377555 +0200   \n>   commit: configure.ac vertical whitespace usage cleanu\n> \n> where \"roke.D-201\" are results of \"hostname -f\" on my computer, and are\n> suitable _only_ for my small private local network.\n> \n> Bug or a feature?\n\nThis is definately a bug.  The reflog uses the same ident code\nthat commit-tree uses, with the idea that GIT_COMMITTER_IDENT would\ndrive the entry in the reflog, as you expected it to.\n\nLooking in refs.c at log_ref_write its invoking setup_ident()\nthen git_committer_info(1).  git_committer_info should be using\nthe environment variables (GIT_COMMITTER_NAME, GIT_COMMITTER_EMAIL,\nGIT_COMMITTER_DATE) with defaults back to the gecos values.  Based\non that it would seem that the user data in .git/config is being\nignored...  Hm.\n\nSo you must be expecting .git/config to be supplying your data but\nits getting overrwritten by setup_ident() in log_ref_write.\n\nHere's the bug fix.  Sorry about that one.  That bug has been in\nthere since the reflog code was first put into GIT.  :-)\n\n-->--\nAllow user.name and user.email to drive reflog entry.\n\nApparently calling setup_ident() after git_config causes the\nuser.name and user.email values read from the config file to be\nreplaced with the data obtained from the host.  This means that\nusers who have setup their email address in user.email will instead\nbe writing reflog entries with their hostname.\n\nMoving setup_ident() to before git_config in update-ref resolves\nthis ordering problem.\n---\n builtin-update-ref.c |    1 +\n refs.c               |    1 -\n 2 files changed, 1 insertions(+), 1 deletions(-)\n\ndiff --git a/builtin-update-ref.c b/builtin-update-ref.c\nindex 00333c7..83094ab 100644\n--- a/builtin-update-ref.c\n+++ b/builtin-update-ref.c\n@@ -12,6 +12,7 @@ int cmd_update_ref(int argc, const char \n \tunsigned char sha1[20], oldsha1[20];\n \tint i;\n \n+\tsetup_ident();\n \tsetup_git_directory();\n \tgit_config(git_default_config);\n \ndiff --git a/refs.c b/refs.c\nindex 2d9c1dc..56db394 100644\n--- a/refs.c\n+++ b/refs.c\n@@ -379,7 +379,6 @@ static int log_ref_write(struct ref_lock\n \t\t\tlock->log_file, strerror(errno));\n \t}\n \n-\tsetup_ident();\n \tcommitter = git_committer_info(1);\n \tif (msg) {\n \t\tmaxlen = strlen(committer) + strlen(msg) + 2*40 + 5;\n-- \n1.4.1.gc48f\n"},{"id":"23603","messageId":"20060711003228.GC10700@spearce.org","threadId":"4839","inReplyTo":"20060711002754.GB10700@spearce.org","subject":"Re: git-update-ref (reflog) uses bogus author ident information","fromName":"Shawn Pearce","fromEmail":"spearce@spearce.org","sentAt":"2006-07-11T00:32:28Z","receivedAt":"2006-07-11T00:32:28Z","isPatch":false,"sender":{"key":"spearce@spearce.org","avatar":"https://avatars.githubusercontent.com/u/34844?v=4"},"body":"Shawn Pearce <spearce@spearce.org> wrote:\n> Allow user.name and user.email to drive reflog entry.\n> \n> Apparently calling setup_ident() after git_config causes the\n> user.name and user.email values read from the config file to be\n> replaced with the data obtained from the host.  This means that\n> users who have setup their email address in user.email will instead\n> be writing reflog entries with their hostname.\n> \n> Moving setup_ident() to before git_config in update-ref resolves\n> this ordering problem.\n\nWhoops, I forgot this line:  :-)\n\nSigned-off-by: Shawn O. Pearce <spearce@spearce.org>\n\n> ---\n>  builtin-update-ref.c |    1 +\n>  refs.c               |    1 -\n>  2 files changed, 1 insertions(+), 1 deletions(-)\n> \n> diff --git a/builtin-update-ref.c b/builtin-update-ref.c\n> index 00333c7..83094ab 100644\n> --- a/builtin-update-ref.c\n> +++ b/builtin-update-ref.c\n> @@ -12,6 +12,7 @@ int cmd_update_ref(int argc, const char \n>  \tunsigned char sha1[20], oldsha1[20];\n>  \tint i;\n>  \n> +\tsetup_ident();\n>  \tsetup_git_directory();\n>  \tgit_config(git_default_config);\n>  \n> diff --git a/refs.c b/refs.c\n> index 2d9c1dc..56db394 100644\n> --- a/refs.c\n> +++ b/refs.c\n> @@ -379,7 +379,6 @@ static int log_ref_write(struct ref_lock\n>  \t\t\tlock->log_file, strerror(errno));\n>  \t}\n>  \n> -\tsetup_ident();\n>  \tcommitter = git_committer_info(1);\n>  \tif (msg) {\n>  \t\tmaxlen = strlen(committer) + strlen(msg) + 2*40 + 5;\n> -- \n> 1.4.1.gc48f\n"},{"id":"23610","messageId":"20060711024847.GD10700@spearce.org","threadId":"4839","inReplyTo":"e8uhvg$5o1$2@sea.gmane.org","subject":"Re: reflog doesn't note that commit was --amend-ed, and doesn't record pulls","fromName":"Shawn Pearce","fromEmail":"spearce@spearce.org","sentAt":"2006-07-11T02:48:47Z","receivedAt":"2006-07-11T02:48:47Z","isPatch":false,"sender":{"key":"spearce@spearce.org","avatar":"https://avatars.githubusercontent.com/u/34844?v=4"},"body":"Jakub Narebski <jnareb@gmail.com> wrote:\n> Additionally, while reflog records git-reset invocations, it doesn't\n> distinguish between an ordinary commit, and commit --amend (which I do\n> a lot, most time because of forgotten update-index; yes, I know about commit\n> -a option ;-). Well, you can extract this information looking at current\n> and previous commit sha1, but it would be nice to have it noted somewhat in\n> message part of reflog.\n\nI'm attaching a patch below which fixes this.  It denotes the 4\nmajor types of commits: initial, normal, amend, merge.\n \n> Reflog doesn't seem also to record pulls (e.g. master branch): pulls has\n> empty reflog message part.\n\nYea, that's a 'TODO' item.  Now that someone is complaining about\nit I'll see if I can't get a fix done later tonight for it.\nIts probably going to be a few patches: one for git-merge and\nanother for receive-pack.c.\n\n-->--\nRecord the type of commit operation in the reflog.\n\nIf committing a merge (.git/MERGE_HEAD exists), an initial tree\n(no HEAD) or using --amend to amend the prior commit then denote\nthe subtype of commit in the reflog.  This helps to distinguish\namended or merge commits from normal commits.\n\nIn the case of --amend the prior sha1 is probably the commit which\nis being thrown away in favor of the new commit.  Since it is likely\nthat the old commit doesn't have any ref pointing to it anymore\nit can be interesting to know why that the commit was replaced\nand orphaned.\n\nIn the case of a merge the prior sha1 is probably the first parent\nof the new merge commit.  Consequently having its prior sha1 in the\nreflog is slightly less interesting but its still informative to\nknow the commit was the result of a merge which had to be completed\nby hand.\n\nSigned-off-by: Shawn O. Pearce <spearce@spearce.org>\n---\n git-commit.sh         |    6 +++++-\n t/t1400-update-ref.sh |   19 ++++++++++++++++---\n 2 files changed, 21 insertions(+), 4 deletions(-)\n\ndiff --git a/git-commit.sh b/git-commit.sh\nindex 22c4ce8..05eccfe 100755\n--- a/git-commit.sh\n+++ b/git-commit.sh\n@@ -635,9 +635,12 @@ fi\n PARENTS=\"-p HEAD\"\n if test -z \"$initial_commit\"\n then\n+\trloga='commit'\n \tif [ -f \"$GIT_DIR/MERGE_HEAD\" ]; then\n+\t\trloga='commit (merge)'\n \t\tPARENTS=\"-p HEAD \"`sed -e 's/^/-p /' \"$GIT_DIR/MERGE_HEAD\"`\n \telif test -n \"$amend\"; then\n+\t\trloga='commit (amend)'\n \t\tPARENTS=$(git-cat-file commit HEAD |\n \t\t\tsed -n -e '/^$/q' -e 's/^parent /-p /p')\n \tfi\n@@ -649,6 +652,7 @@ else\n \tfi\n \tPARENTS=\"\"\n \tcurrent=\n+\trloga='commit (initial)'\n fi\n \n if test -z \"$no_edit\"\n@@ -724,7 +728,7 @@ then\n \tfi &&\n \tcommit=$(cat \"$GIT_DIR\"/COMMIT_MSG | git-commit-tree $tree $PARENTS) &&\n \trlogm=$(sed -e 1q \"$GIT_DIR\"/COMMIT_MSG) &&\n-\tgit-update-ref -m \"commit: $rlogm\" HEAD $commit $current &&\n+\tgit-update-ref -m \"$rloga: $rlogm\" HEAD $commit $current &&\n \trm -f -- \"$GIT_DIR/MERGE_HEAD\" &&\n \tif test -f \"$NEXT_INDEX\"\n \tthen\ndiff --git a/t/t1400-update-ref.sh b/t/t1400-update-ref.sh\nindex df3e993..6a3515d 100755\n--- a/t/t1400-update-ref.sh\n+++ b/t/t1400-update-ref.sh\n@@ -188,17 +188,30 @@ test_expect_success \\\n \t echo OTHER >F &&\n \t GIT_AUTHOR_DATE=\"2005-05-26 23:41\" \\\n \t GIT_COMMITTER_DATE=\"2005-05-26 23:41\" git-commit -F M -a &&\n-\t h_OTHER=$(git-rev-parse --verify HEAD)\n+\t h_OTHER=$(git-rev-parse --verify HEAD) &&\n+\t echo FIXED >F &&\n+\t EDITOR=true \\\n+\t GIT_AUTHOR_DATE=\"2005-05-26 23:44\" \\\n+\t GIT_COMMITTER_DATE=\"2005-05-26 23:44\" git-commit --amend &&\n+\t h_FIXED=$(git-rev-parse --verify HEAD) &&\n+\t echo TEST+FIXED >F &&\n+\t echo Merged initial commit and a later commit. >M &&\n+\t echo $h_TEST >.git/MERGE_HEAD &&\n+\t GIT_AUTHOR_DATE=\"2005-05-26 23:45\" \\\n+\t GIT_COMMITTER_DATE=\"2005-05-26 23:45\" git-commit -F M &&\n+\t h_MERGED=$(git-rev-parse --verify HEAD)\n \t rm -f M'\n \n cat >expect <<EOF\n-$Z $h_TEST $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> 1117150200 +0000\tcommit: add\n+$Z $h_TEST $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> 1117150200 +0000\tcommit (initial): add\n $h_TEST $h_OTHER $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> 1117150860 +0000\tcommit: The other day this did not work.\n+$h_OTHER $h_FIXED $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> 1117151040 +0000\tcommit (amend): The other day this did not work.\n+$h_FIXED $h_MERGED $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> 1117151100 +0000\tcommit (merge): Merged initial commit and a later commit.\n EOF\n test_expect_success \\\n \t'git-commit logged updates' \\\n \t'diff expect .git/logs/$m'\n-unset h_TEST h_OTHER\n+unset h_TEST h_OTHER h_FIXED h_MERGED\n \n test_expect_success \\\n \t'git-cat-file blob master:F (expect OTHER)' \\\n-- \n1.4.1.gc48f\n"},{"id":"23612","messageId":"20060711033835.GA11332@spearce.org","threadId":"4839","inReplyTo":"e8uhvg$5o1$2@sea.gmane.org","subject":"Re: reflog doesn't note that commit was --amend-ed, and doesn't record pulls","fromName":"Shawn Pearce","fromEmail":"spearce@spearce.org","sentAt":"2006-07-11T03:38:35Z","receivedAt":"2006-07-11T03:38:35Z","isPatch":false,"sender":{"key":"spearce@spearce.org","avatar":"https://avatars.githubusercontent.com/u/34844?v=4"},"body":"Jakub Narebski <jnareb@gmail.com> wrote:\n> Reflog doesn't seem also to record pulls (e.g. master branch): pulls has\n> empty reflog message part.\n\nFixed with the patch below.  git-merge doesn't record the merges yet,\nso some changes made by git-pull still aren't logged as nicely as\none would like.  But don't fear, that will be coming soon.  :-)\n\n-->--\nLog ref changes made by git-fetch and git-pull.\n\nWhen git-fetch updates a reference record in the associated reflog\nwhat type of update took place and who caused it (git-fetch or\ngit-pull, by invoking git-fetch).\n\nSigned-off-by: Shawn O. Pearce <spearce@spearce.org>\n---\n git-fetch.sh |   20 +++++++++++++++-----\n git-pull.sh  |    2 +-\n 2 files changed, 16 insertions(+), 6 deletions(-)\n\ndiff --git a/git-fetch.sh b/git-fetch.sh\nindex 48818f8..5e4c4d6 100755\n--- a/git-fetch.sh\n+++ b/git-fetch.sh\n@@ -11,6 +11,7 @@ LF='\n '\n IFS=\"$LF\"\n \n+rloga=fetch\n no_tags=\n tags=\n append=\n@@ -51,6 +52,9 @@ do\n \t-k|--k|--ke|--kee|--keep)\n \t\tkeep=--keep\n \t\t;;\n+\t--reflog-action=*)\n+\t\trloga=`expr \"z$1\" : 'z-[^=]*=\\(.*\\)'`\n+\t\t;;\n \t-*)\n \t\tusage\n \t\t;;\n@@ -75,6 +79,9 @@ refs=\n rref=\n rsync_slurped_objects=\n \n+rloga=\"$rloga $remote_nick\"\n+test \"$remote_nick\" == \"$remote\" || rloga=\"$rloga $remote\"\n+\n if test \"\" = \"$append\"\n then\n \t: >\"$GIT_DIR/FETCH_HEAD\"\n@@ -149,11 +156,12 @@ fast_forward_local () {\n \t\t\t[ \"$verbose\" ] && echo >&2 \"* $1: same as $3\"\n \t\telse\n \t\t\techo >&2 \"* $1: updating with $3\"\n+\t\t\tgit-update-ref -m \"$rloga: updating tag\" \"$1\" \"$2\"\n \t\tfi\n \telse\n \t\techo >&2 \"* $1: storing $3\"\n+\t\tgit-update-ref -m \"$rloga: storing tag\" \"$1\" \"$2\"\n \tfi\n-\tgit-update-ref \"$1\" \"$2\"\n \t;;\n \n     refs/heads/* | refs/remotes/*)\n@@ -174,7 +182,7 @@ fast_forward_local () {\n \t    *,$local)\n \t\techo >&2 \"* $1: fast forward to $3\"\n \t\techo >&2 \"  from $local to $2\"\n-\t\tgit-update-ref \"$1\" \"$2\" \"$local\"\n+\t\tgit-update-ref -m \"$rloga: fast-forward\" \"$1\" \"$2\" \"$local\"\n \t\t;;\n \t    *)\n \t\tfalse\n@@ -184,7 +192,7 @@ fast_forward_local () {\n \t\tcase \",$force,$single_force,\" in\n \t\t*,t,*)\n \t\t\techo >&2 \"  forcing update.\"\n-\t\t\tgit-update-ref \"$1\" \"$2\" \"$local\"\n+\t\t\tgit-update-ref -m \"$rloga: forced-update\" \"$1\" \"$2\" \"$local\"\n \t\t\t;;\n \t\t*)\n \t\t\techo >&2 \"  not updating.\"\n@@ -194,7 +202,7 @@ fast_forward_local () {\n \t    }\n \telse\n \t    echo >&2 \"* $1: storing $3\"\n-\t    git-update-ref \"$1\" \"$2\"\n+\t    git-update-ref -m \"$rloga: storing head\" \"$1\" \"$2\"\n \tfi\n \t;;\n     esac\n@@ -422,7 +430,9 @@ case \",$update_head_ok,$orig_head,\" in\n \tcurr_head=$(git-rev-parse --verify HEAD 2>/dev/null)\n \tif test \"$curr_head\" != \"$orig_head\"\n \tthen\n-\t    \tgit-update-ref HEAD \"$orig_head\"\n+\t    git-update-ref \\\n+\t\t\t-m \"$rloga: Undoing incorrectly fetched HEAD.\" \\\n+\t\t\tHEAD \"$orig_head\"\n \t\tdie \"Cannot fetch into the current branch.\"\n \tfi\n \t;;\ndiff --git a/git-pull.sh b/git-pull.sh\nindex 076785c..d337bf4 100755\n--- a/git-pull.sh\n+++ b/git-pull.sh\n@@ -45,7 +45,7 @@ do\n done\n \n orig_head=$(git-rev-parse --verify HEAD) || die \"Pulling into a black hole?\"\n-git-fetch --update-head-ok \"$@\" || exit 1\n+git-fetch --update-head-ok --reflog-action=pull \"$@\" || exit 1\n \n curr_head=$(git-rev-parse --verify HEAD)\n if test \"$curr_head\" != \"$orig_head\"\n-- \n1.4.1.gc48f\n"}]}