mbox series

[v3,0/4] Use refs API for handling sundry pseudorefs

Message ID pull.706.v3.git.1598029177.gitgitgadget@gmail.com (mailing list archive)
Headers show
Series Use refs API for handling sundry pseudorefs | expand

Message

Philippe Blain via GitGitGadget Aug. 21, 2020, 4:59 p.m. UTC
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 | 26 +++++++++++-----------
 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, 57 insertions(+), 48 deletions(-)


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

Range-diff vs v2:

 1:  a8467a0d66 = 1:  bfea176682 refs: make refs_ref_exists public
 2:  2797e98446 = 2:  5ff5d2c663 sequencer: treat CHERRY_PICK_HEAD as a pseudo ref
 3:  2681638651 ! 3:  8aacde69c8 builtin/commit: suggest update-ref for pseudoref removal
     @@ Commit message
      
       ## builtin/commit.c ##
      @@ builtin/commit.c: static int prepare_to_commit(const char *index_file, const char *prefix,
     - 		struct ident_split ci, ai;
     - 
     - 		if (whence != FROM_COMMIT) {
     -+			const char *pseudoref = (whence == FROM_MERGE) ?
     -+							      "MERGE_HEAD" :
     -+							      "CHERRY_PICK_HEAD";
     -+			const char *what = (whence == FROM_MERGE) ?
     -+							 "merge" :
     -+							 "cherry-pick";
     -+
       			if (cleanup_mode == COMMIT_MSG_CLEANUP_SCISSORS &&
       				!merge_contains_scissors)
       				wt_status_add_cut_line(s->fp);
     @@ builtin/commit.c: static int prepare_to_commit(const char *index_file, const cha
      -					"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));
      +			status_printf_ln(
      +				s, GIT_COLOR_NORMAL,
     -+				_("\n"
     -+				  "It looks like you may be committing a %s.\n"
     -+				  "If this is not correct, please remove %s with\n"
     -+				  "	git update-ref -d %s\n"
     -+				  "and try again.\n"),
     -+				what, pseudoref, pseudoref);
     + 				whence == FROM_MERGE ?
     +-					git_path_merge_head(the_repository) :
     +-					git_path_cherry_pick_head(the_repository));
     ++					      _("\n"
     ++					  "It looks like you may be committing a merge.\n"
     ++					  "If this is not correct, please run\n"
     ++					  "	git update-ref -d MERGE_HEAD\n"
     ++					  "and try again.\n") :
     ++					      _("\n"
     ++					  "It looks like you may be committing a cherry-pick.\n"
     ++					  "If this is not correct, please run\n"
     ++					  "	git update-ref -d CHERRY_PICK_HEAD\n"
     ++					  "and try again.\n"));
       		}
       
       		fprintf(s->fp, "\n");
 4:  9dcc10f807 = 4:  9ba0136645 sequencer: treat REVERT_HEAD as a pseudo ref

Comments

Junio C Hamano Aug. 21, 2020, 6:34 p.m. UTC | #1
"Han-Wen Nienhuys via GitGitGadget" <gitgitgadget@gmail.com> writes:

> 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

Thanks.