sequencer: use memoized sequencer directory path
authorJohannes Schindelin <johannes.schindelin@gmx.de>
Fri, 14 Oct 2016 13:17:12 +0000 (15:17 +0200)
committerJunio C Hamano <gitster@pobox.com>
Mon, 17 Oct 2016 18:52:23 +0000 (11:52 -0700)
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin/commit.c
sequencer.c
sequencer.h
index 1cba3b75c8dc121cf86558aa96726ea99f28eba3..9fddb195c5588d651c8cd0c0b43ec11ab145f5ec 100644 (file)
@@ -183,7 +183,7 @@ static void determine_whence(struct wt_status *s)
                whence = FROM_MERGE;
        else if (file_exists(git_path_cherry_pick_head())) {
                whence = FROM_CHERRY_PICK;
-               if (file_exists(git_path(SEQ_DIR)))
+               if (file_exists(git_path_seq_dir()))
                        sequencer_in_use = 1;
        }
        else
index eec8a60d6bdf22d429c14ad07288f823d9bac7b5..cb16cbda3521de5121b69ad96a0b02b4c9bfe3e3 100644 (file)
 const char sign_off_header[] = "Signed-off-by: ";
 static const char cherry_picked_prefix[] = "(cherry picked from commit ";
 
-static GIT_PATH_FUNC(git_path_todo_file, SEQ_TODO_FILE)
-static GIT_PATH_FUNC(git_path_opts_file, SEQ_OPTS_FILE)
-static GIT_PATH_FUNC(git_path_seq_dir, SEQ_DIR)
-static GIT_PATH_FUNC(git_path_head_file, SEQ_HEAD_FILE)
+GIT_PATH_FUNC(git_path_seq_dir, "sequencer")
+
+static GIT_PATH_FUNC(git_path_todo_file, "sequencer/todo")
+static GIT_PATH_FUNC(git_path_opts_file, "sequencer/opts")
+static GIT_PATH_FUNC(git_path_head_file, "sequencer/head")
 
 static int is_rfc2822_line(const char *buf, int len)
 {
@@ -112,7 +113,7 @@ static void remove_sequencer_state(void)
 {
        struct strbuf seq_dir = STRBUF_INIT;
 
-       strbuf_addstr(&seq_dir, git_path(SEQ_DIR));
+       strbuf_addstr(&seq_dir, git_path_seq_dir());
        remove_dir_recursively(&seq_dir, 0);
        strbuf_release(&seq_dir);
 }
index db425ad1a6f2ee5e487ff17a71c2ba3e115f53ac..dd4d33a5723737d8cdd44a138c666997802afd23 100644 (file)
@@ -1,10 +1,7 @@
 #ifndef SEQUENCER_H
 #define SEQUENCER_H
 
-#define SEQ_DIR                "sequencer"
-#define SEQ_HEAD_FILE  "sequencer/head"
-#define SEQ_TODO_FILE  "sequencer/todo"
-#define SEQ_OPTS_FILE  "sequencer/opts"
+const char *git_path_seq_dir(void);
 
 #define APPEND_SIGNOFF_DEDUP (1u << 0)