[PATCH 00/19] reset improvements
This is kind of a re-roll of [1] (wow, apparently it took me almost two months to get done). The goal was, then and now, to teach "git reset" to work on an unborn branch and to not require a commit when a tree would do. This time, I also made some tangential improvements along the way, mostly related to readability and performance.
As usual, the risker patches are towards the end. In particular, I find it hard to evaluate how risky the last patch is. That last patch is responsible for much of the improvements in the timing table below, so it would be nice if it doesn't break things too badly (test pass, of course). The timings are best-of-five, wall time.
Command Before After reset (warm) 0.23 0.07 reset -q (warm) 0.23 0.03 reset . (warm) 0.09 0.07 reset -q . (warm) 0.09 0.03 reset --keep (warm) 0.31 0.29 reset --keep -q (warm) 0.31 0.29 reset (cold) 9.74 2.60 reset -q (cold) 9.85 0.37 reset . (cold) 2.66 2.51 reset -q . (cold) 2.59 0.33 reset --keep (cold) 7.58 7.52 reset --keep -q (cold) 7.37 7.21
[1] http://thread.gmane.org/gmane.comp.version-control.git/210568/focus=210855
Martin von Zweigbergk (19):
reset $pathspec: no need to discard index
reset $pathspec: exit with code 0 if successful
reset.c: pass pathspec around instead of (prefix, argv) pair
reset: don't allow "git reset -- $pathspec" in bare repo
reset.c: extract function for parsing arguments
reset.c: remove unnecessary variable 'i'
reset.c: extract function for updating {ORIG,}HEAD
reset.c: share call to die_if_unmerged_cache()
reset.c: replace switch by if-else
reset --keep: only write index file once
reset: avoid redundant error message
reset.c: move update_index_refresh() call out of read_from_tree()
reset.c: move lock, write and commit out of update_index_refresh()
reset [--mixed]: don't write index file twice
reset.c: finish entire cmd_reset() whether or not pathspec is given
reset [--mixed] --quiet: don't refresh index
reset $sha1 $pathspec: require $sha1 only to be treeish
reset: allow reset on unborn branch
reset [--mixed]: use diff-based reset whether or not pathspec was
givenbuiltin/reset.c | 281 +++++++++++++++++++---------------------- t/t2013-checkout-submodule.sh | 2 +- t/t7102-reset.sh | 26 +++- t/t7106-reset-unborn-branch.sh | 52 ++++++++ 4 files changed, 200 insertions(+), 161 deletions(-) create mode 100755 t/t7106-reset-unborn-branch.sh
-- 1.8.1.rc3.331.g1ef2165