Nicolas Pitre <nico@xxxxxxx> writes: >> Nicolas Pitre <nico@xxxxxxx> writes: >> >> > SYNOPSIS >> > >> > git-local-arrival <committish> >> > >> > DESCRIPTION >> > >> > The command displays the time when given commit appeared in the >> > local repository. >> >> This should be certainly doable, but local-arrival may not be >> interesting if the repository has more than one branches. Maybe >> >> git-local-arrival <committish> [<branch>] >> >> which defaults to the current branch? > > Indeed. I didn't mention it initially because it is really easy to do > once you have it working for the current branch. The technical > challenge is about making it efficient to find out which reflog entry > with a path to given commit is the oldest. Perhaps bisect it like this. This assumes you never rewind the branch in question and the tip already contains the commit in question. -- >8 -- #!/bin/sh . git-sh-setup commit=`git rev-parse "$1"` && branch="${2-`git symbolic-ref HEAD`} || exit contains () { contains=`git merge-base --all $1 $commit` case "$LF$contains$LF" in *"$LF$contains$LF"*) : ;; *) false ;; esac } LF=' ' script='{ s/ .*// p }' ;# strip things after TAB if a TAB exists reflog="$GIT_DIR/logs/refs/heads/$branch"; lo=1; hi=`wc -l <$reflog` ld=$hi while expr "$lo" \< "$hi" >/dev/null do mi=`expr \( $hi \+ $lo \) / 2` line=`sed -ne "$mi$script" "$reflog"` to=`expr "$line" : '[^ ]* \([^ ]*\) '` if contains $to then ld=$hi hi=$mi else lo=`expr "$mi" + 1` fi done case "$ld" in '') echo >&2 Oops exit 1;; ?*) line=`sed -ne "$ld$script" "$reflog"` time=`expr "$line" : '.*> \([0-9]*\) '` zone=`expr "$line" : '.*> [0-9]* \(.[0-9][0-9][0-9][0-9]\)$'` echo "$time $zone" esac - To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html