From: Elijah Newren <newren@gmail.com>
To: git@vger.kernel.org
Cc: Elijah Newren <newren@gmail.com>
Subject: [RFC/PATCH 16/18] git-merge-one-file.sh: support --index-only option
Date: Thu, 7 Apr 2016 23:58:44 -0700 [thread overview]
Message-ID: <1460098726-5958-17-git-send-email-newren@gmail.com> (raw)
In-Reply-To: <1460098726-5958-1-git-send-email-newren@gmail.com>
Signed-off-by: Elijah Newren <newren@gmail.com>
---
git-merge-one-file.sh | 44 +++++++++++++++++++++++++++++++++++---------
1 file changed, 35 insertions(+), 9 deletions(-)
diff --git a/git-merge-one-file.sh b/git-merge-one-file.sh
index 424b034..78efa00 100755
--- a/git-merge-one-file.sh
+++ b/git-merge-one-file.sh
@@ -18,16 +18,25 @@
USAGE='<orig blob> <our blob> <their blob> <path>'
USAGE="$USAGE <orig mode> <our mode> <their mode>"
-LONG_USAGE="usage: git merge-one-file $USAGE
+LONG_USAGE="usage: git merge-one-file $USAGE [--index-only]
Blob ids and modes should be empty for missing files."
+update_worktree=t
+expected_argcount=7
+if test "$8" = "--index-only"; then
+ update_worktree=
+ expected_argcount=8
+fi
+
SUBDIRECTORY_OK=Yes
. git-sh-setup
cd_to_toplevel
-require_work_tree
+if test -n "$update_worktree"; then
+ require_work_tree
+fi
-if test $# != 7
+if test $# != $expected_argcount
then
echo "$LONG_USAGE"
exit 1
@@ -59,8 +68,10 @@ case "${1:-.}${2:-.}${3:-.}" in
fi
if test -f "$4"
then
- rm -f -- "$4" &&
- rmdir -p "$(expr "z$4" : 'z\(.*\)/')" 2>/dev/null || :
+ if test -n "$update_worktree"; then
+ rm -f -- "$4" &&
+ rmdir -p "$(expr "z$4" : 'z\(.*\)/')" 2>/dev/null || :
+ fi
fi &&
exec git update-index --remove -- "$4"
;;
@@ -80,8 +91,11 @@ case "${1:-.}${2:-.}${3:-.}" in
echo "ERROR: untracked $4 is overwritten by the merge." >&2
exit 1
fi
- git update-index --add --cacheinfo "$7" "$3" "$4" &&
+ git update-index --add --cacheinfo "$7" "$3" "$4"
+ if test -n "$update_worktree"; then
exec git checkout-index -u -f -- "$4"
+ fi
+ exit 0
;;
#
@@ -95,8 +109,11 @@ case "${1:-.}${2:-.}${3:-.}" in
exit 1
fi
echo "Adding $4"
- git update-index --add --cacheinfo "$6" "$2" "$4" &&
+ git update-index --add --cacheinfo "$6" "$2" "$4"
+ if test -n "$update_worktree"; then
exec git checkout-index -u -f -- "$4"
+ fi
+ exit 0
;;
#
@@ -139,7 +156,11 @@ case "${1:-.}${2:-.}${3:-.}" in
# Create the working tree file, using "our tree" version from the
# index, and then store the result of the merge.
- git checkout-index -f --stage=2 -- "$4" && cat "$src1" >"$4" || exit 1
+ if test -n "$update_worktree"; then
+ git checkout-index -f --stage=2 -- "$4" && cat "$src1" >"$4" || exit 1
+ else
+ sha1=$(git hash-object -w -- "$src1")
+ fi
rm -f -- "$orig" "$src1" "$src2"
if test "$6" != "$7"
@@ -157,7 +178,12 @@ case "${1:-.}${2:-.}${3:-.}" in
echo "ERROR: $msg in $4" >&2
exit 1
fi
- exec git update-index -- "$4"
+ if test -n "$update_worktree"; then
+ exec git update-index -- "$4"
+ else
+ printf "$6 $sha1\t$4" | git update-index --index-info
+ exit $?
+ fi
;;
*)
--
2.8.0.18.gc685494
next prev parent reply other threads:[~2016-04-08 6:59 UTC|newest]
Thread overview: 30+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-04-08 6:58 [RFC/PATCH 00/18] Add --index-only option to git merge Elijah Newren
2016-04-08 6:58 ` [RFC/PATCH 01/18] Remove duplicate code Elijah Newren
2016-04-08 23:34 ` Junio C Hamano
2016-04-08 6:58 ` [RFC/PATCH 02/18] Avoid checking working copy when creating a virtual merge base Elijah Newren
2016-04-08 6:58 ` [RFC/PATCH 03/18] Document weird bug in octopus merges via testcases Elijah Newren
2016-04-08 6:58 ` [RFC/PATCH 04/18] merge-octopus: Abort if index not clean Elijah Newren
2016-04-08 19:31 ` Junio C Hamano
2016-04-08 6:58 ` [RFC/PATCH 05/18] Add testcase for --index-only merges needing the recursive strategy Elijah Newren
2016-04-08 19:37 ` Junio C Hamano
2016-04-08 20:14 ` Junio C Hamano
2016-04-08 6:58 ` [RFC/PATCH 06/18] Add testcase for --index-only merges needing an ff update Elijah Newren
2016-04-08 6:58 ` [RFC/PATCH 07/18] Add testcase for --index-only merges with the resolve strategy Elijah Newren
2016-04-08 6:58 ` [RFC/PATCH 08/18] Add testcase for --index-only merges with the octopus strategy Elijah Newren
2016-04-08 6:58 ` [RFC/PATCH 09/18] Add testcase for --index-only merges with the ours strategy Elijah Newren
2016-04-08 6:58 ` [RFC/PATCH 10/18] Add testcase for --index-only merges with the subtree strategy Elijah Newren
2016-04-08 6:58 ` [RFC/PATCH 11/18] merge: Add a new --index-only option, not yet implemented Elijah Newren
2016-04-08 22:33 ` Junio C Hamano
2016-04-08 6:58 ` [RFC/PATCH 12/18] Add --index-only support for recursive merges Elijah Newren
2016-04-08 6:58 ` [RFC/PATCH 13/18] Add --index-only support with read_tree_trivial merges, kind of Elijah Newren
2016-04-08 6:58 ` [RFC/PATCH 14/18] Add --index-only support for ff_only merges Elijah Newren
2016-04-08 6:58 ` [RFC/PATCH 15/18] merge: Pass --index-only along to external merge strategy programs Elijah Newren
2016-04-08 6:58 ` Elijah Newren [this message]
2016-04-08 6:58 ` [RFC/PATCH 17/18] git-merge-resolve.sh: support --index-only option Elijah Newren
2016-04-08 6:58 ` [RFC/PATCH 18/18] git-merge-octopus.sh: " Elijah Newren
2016-04-08 13:01 ` [RFC/PATCH 00/18] Add --index-only option to git merge Michael J Gruber
2016-04-09 3:09 ` Elijah Newren
2016-04-08 18:08 ` Junio C Hamano
2016-04-09 2:35 ` Elijah Newren
2016-04-09 4:44 ` Junio C Hamano
2016-04-10 5:33 ` Elijah Newren
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: http://vger.kernel.org/majordomo-info.html
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1460098726-5958-17-git-send-email-newren@gmail.com \
--to=newren@gmail.com \
--cc=git@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://80x24.org/mirrors/git.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).