[PATCH 7/9] am/rebase: update pseudorefs by writing files

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



git update-ref can no longer be used to update pseudorefs, so in
git-am and git-rebase, we just directly edit the files.

Signed-off-by: David Turner <dturner@xxxxxxxxxxxxxxxx>
---
 builtin/am.c               | 6 +++---
 contrib/examples/git-am.sh | 4 ++--
 git-rebase--interactive.sh | 2 +-
 git-rebase.sh              | 2 +-
 4 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/builtin/am.c b/builtin/am.c
index 3f0fc75..ff3eeee 100644
--- a/builtin/am.c
+++ b/builtin/am.c
@@ -1049,12 +1049,12 @@ static void am_setup(struct am_state *state, enum patch_format patch_format,
 	if (!get_sha1("HEAD", curr_head)) {
 		write_file(am_path(state, "abort-safety"), 1, "%s", sha1_to_hex(curr_head));
 		if (!state->rebasing)
-			update_ref("am", "ORIG_HEAD", curr_head, NULL, 0,
-					UPDATE_REFS_DIE_ON_ERR);
+			write_pseudoref("ORIG_HEAD", curr_head, NULL);
 	} else {
 		write_file(am_path(state, "abort-safety"), 1, "%s", "");
 		if (!state->rebasing)
-			delete_ref("ORIG_HEAD", NULL, 0);
+			if (unlink(git_path("ORIG_HEAD")) && errno != ENOENT)
+				die("failed to unlink ORIG_HEAD");
 	}
 
 	/*
diff --git a/contrib/examples/git-am.sh b/contrib/examples/git-am.sh
index a3d0c84..a01a06e 100755
--- a/contrib/examples/git-am.sh
+++ b/contrib/examples/git-am.sh
@@ -614,9 +614,9 @@ Use \"git am --abort\" to remove it.")"
 		: >"$dotest/applying"
 		if test -n "$HAS_HEAD"
 		then
-			git update-ref ORIG_HEAD HEAD
+			git rev-parse HEAD >"$GIT_DIR/ORIG_HEAD"
 		else
-			git update-ref -d ORIG_HEAD >/dev/null 2>&1
+			rm -f "$GIT_DIR/ORIG_HEAD"
 		fi
 	fi
 fi
diff --git a/git-rebase--interactive.sh b/git-rebase--interactive.sh
index f01637b..ae116a6 100644
--- a/git-rebase--interactive.sh
+++ b/git-rebase--interactive.sh
@@ -948,7 +948,7 @@ warn_lines () {
 checkout_onto () {
 	GIT_REFLOG_ACTION="$GIT_REFLOG_ACTION: checkout $onto_name"
 	output git checkout $onto || die_abort "could not detach HEAD"
-	git update-ref ORIG_HEAD $orig_head
+	echo $orig_head >"$GIT_DIR/ORIG_HEAD"
 }
 
 get_missing_commit_check_level () {
diff --git a/git-rebase.sh b/git-rebase.sh
index 1757404..23e2e64 100755
--- a/git-rebase.sh
+++ b/git-rebase.sh
@@ -611,7 +611,7 @@ say "$(gettext "First, rewinding head to replay your work on top of it...")"
 
 GIT_REFLOG_ACTION="$GIT_REFLOG_ACTION: checkout $onto_name" \
 	git checkout -q "$onto^0" || die "could not detach HEAD"
-git update-ref ORIG_HEAD $orig_head
+echo $orig_head >"$GIT_DIR/ORIG_HEAD"
 
 # If the $onto is a proper descendant of the tip of the branch, then
 # we just fast-forwarded.
-- 
2.0.4.315.gad8727a-twtrsrc

--
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



[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]