Subject: [PATCH v2 0/4] Use refs API for handling sundry pseudorefs

From: "Han-Wen Nienhuys via GitGitGadget" <[email-masked]>
Date: Wed, 19 Aug 2020 15:15:23 +0000

This series changes the handling of CHERRY_PICK_HEAD and REVERT_HEAD to use
the refs API, as a preliminary refactor for reftable. 

No functional changes.

Han-Wen Nienhuys (4):
  refs: make refs_ref_exists public
  sequencer: treat CHERRY_PICK_HEAD as a pseudo ref
  builtin/commit: suggest update-ref for pseudoref removal
  sequencer: treat REVERT_HEAD as a pseudo ref

 builtin/commit.c | 30 +++++++++++++-------------
 builtin/merge.c  |  2 +-
 path.c           |  2 --
 path.h           |  9 ++++----
 refs.c           |  2 +-
 refs.h           |  2 ++
 sequencer.c      | 56 +++++++++++++++++++++++++++++-------------------
 wt-status.c      |  6 +++---
 8 files changed, 60 insertions(+), 49 deletions(-)

base-commit: 2befe97201e1f3175cce557866c5822793624b5a
Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-706%2Fhanwen%2Fstray-pseudorefs-v2
Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-706/hanwen/stray-pseudorefs-v2
Pull-Request: https://github.com/gitgitgadget/git/pull/706

Range-diff vs v1:

 1:  5e29fa74dc ! 1:  a8467a0d66 Make refs_ref_exists public
     @@ Metadata
      Author: Han-Wen Nienhuys <[email-masked]>
      
       ## Commit message ##
     -    Make refs_ref_exists public
     +    refs: make refs_ref_exists public
     +
     +    This will be necessary to replace file existence checks for pseudorefs.
      
          Signed-off-by: Han-Wen Nienhuys <[email-masked]>
      
 2:  06a8e8cbd1 ! 2:  2797e98446 Treat CHERRY_PICK_HEAD as a pseudo ref
     @@ Metadata
      Author: Han-Wen Nienhuys <[email-masked]>
      
       ## Commit message ##
     -    Treat CHERRY_PICK_HEAD as a pseudo ref
     +    sequencer: treat CHERRY_PICK_HEAD as a pseudo ref
      
          Check for existence and delete CHERRY_PICK_HEAD through ref functions.
          This will help cherry-pick work with alternate ref storage backends.
      
          Signed-off-by: Han-Wen Nienhuys <[email-masked]>
      
     - ## builtin/commit.c ##
     -@@ builtin/commit.c: static int prepare_to_commit(const char *index_file, const char *prefix,
     - 			if (cleanup_mode == COMMIT_MSG_CLEANUP_SCISSORS &&
     - 				!merge_contains_scissors)
     - 				wt_status_add_cut_line(s->fp);
     --			status_printf_ln(s, GIT_COLOR_NORMAL,
     --			    whence == FROM_MERGE
     --				? _("\n"
     --					"It looks like you may be committing a merge.\n"
     --					"If this is not correct, please remove the file\n"
     --					"	%s\n"
     --					"and try again.\n")
     --				: _("\n"
     --					"It looks like you may be committing a cherry-pick.\n"
     --					"If this is not correct, please remove the file\n"
     --					"	%s\n"
     --					"and try again.\n"),
     --				whence == FROM_MERGE ?
     --					git_path_merge_head(the_repository) :
     --					git_path_cherry_pick_head(the_repository));
     -+			if (whence == FROM_MERGE)
     -+				status_printf_ln(
     -+					s, GIT_COLOR_NORMAL,
     -+
     -+					_("\n"
     -+					  "It looks like you may be committing a merge.\n"
     -+					  "If this is not correct, please remove the file\n"
     -+					  "	%s\n"
     -+					  "and try again.\n"),
     -+					git_path_merge_head(the_repository));
     -+			else
     -+				status_printf_ln(
     -+					s, GIT_COLOR_NORMAL,
     -+
     -+					_("\n"
     -+					  "It looks like you may be committing a cherry-pick.\n"
     -+					  "If this is not correct, please run\n"
     -+					  "	git cherry-pick --abort\n"
     -+					  "and try again.\n"));
     - 		}
     - 
     - 		fprintf(s->fp, "\n");
     -
       ## builtin/merge.c ##
      @@ builtin/merge.c: int cmd_merge(int argc, const char **argv, const char *prefix)
       		else
 -:  ---------- > 3:  2681638651 builtin/commit: suggest update-ref for pseudoref removal
 3:  173d81dbb4 ! 4:  9dcc10f807 Treat REVERT_HEAD as a pseudo ref
     @@ Metadata
      Author: Han-Wen Nienhuys <[email-masked]>
      
       ## Commit message ##
     -    Treat REVERT_HEAD as a pseudo ref
     +    sequencer: treat REVERT_HEAD as a pseudo ref
      
          Signed-off-by: Han-Wen Nienhuys <[email-masked]>

-- 
gitgitgadget