mirror of
https://github.com/libgit2/libgit2.git
synced 2026-06-22 06:26:26 +00:00
refs: rename GIT_STASH_FILE to indicate this is a ref
The GIT_STASH_FILE define contains the path to the stash reference. While we know that this used to be a file with the "files" backend, it's not a standalone file with the "reftable" backend anymore. Rename the macro to GIT_STASH_REF to indicate that this is a proper ref.
This commit is contained in:
@@ -41,6 +41,7 @@ extern bool git_reference__enable_symbolic_ref_target_validation;
|
||||
#define GIT_ORIG_HEAD_REF "ORIG_HEAD"
|
||||
#define GIT_REVERT_HEAD_REF "REVERT_HEAD"
|
||||
#define GIT_CHERRYPICK_HEAD_REF "CHERRY_PICK_HEAD"
|
||||
#define GIT_STASH_REF GIT_REFS_DIR "stash"
|
||||
|
||||
#define GIT_HEAD_FILE "HEAD"
|
||||
#define GIT_FETCH_HEAD_FILE "FETCH_HEAD"
|
||||
@@ -57,9 +58,6 @@ extern bool git_reference__enable_symbolic_ref_target_validation;
|
||||
#define GIT_SEQUENCER_OPTIONS_FILE GIT_SEQUENCER_DIR "options"
|
||||
#define GIT_SEQUENCER_TODO_FILE GIT_SEQUENCER_DIR "todo"
|
||||
|
||||
#define GIT_STASH_FILE "stash"
|
||||
#define GIT_REFS_STASH_FILE GIT_REFS_DIR GIT_STASH_FILE
|
||||
|
||||
#define GIT_REFERENCE_FORMAT__PRECOMPOSE_UNICODE (1u << 16)
|
||||
#define GIT_REFERENCE_FORMAT__VALIDATION_DISABLE (1u << 15)
|
||||
|
||||
|
||||
@@ -555,10 +555,10 @@ static int update_reflog(
|
||||
git_reference *stash;
|
||||
int error;
|
||||
|
||||
if ((error = git_reference_ensure_log(repo, GIT_REFS_STASH_FILE)) < 0)
|
||||
if ((error = git_reference_ensure_log(repo, GIT_STASH_REF)) < 0)
|
||||
return error;
|
||||
|
||||
error = git_reference_create(&stash, repo, GIT_REFS_STASH_FILE, w_commit_oid, 1, message);
|
||||
error = git_reference_create(&stash, repo, GIT_STASH_REF, w_commit_oid, 1, message);
|
||||
|
||||
git_reference_free(stash);
|
||||
|
||||
@@ -779,10 +779,10 @@ static int retrieve_stash_commit(
|
||||
size_t max;
|
||||
const git_reflog_entry *entry;
|
||||
|
||||
if ((error = git_reference_lookup(&stash, repo, GIT_REFS_STASH_FILE)) < 0)
|
||||
if ((error = git_reference_lookup(&stash, repo, GIT_STASH_REF)) < 0)
|
||||
goto cleanup;
|
||||
|
||||
if ((error = git_reflog_read(&reflog, repo, GIT_REFS_STASH_FILE)) < 0)
|
||||
if ((error = git_reflog_read(&reflog, repo, GIT_STASH_REF)) < 0)
|
||||
goto cleanup;
|
||||
|
||||
max = git_reflog_entrycount(reflog);
|
||||
@@ -1188,7 +1188,7 @@ int git_stash_foreach(
|
||||
size_t i, max;
|
||||
const git_reflog_entry *entry;
|
||||
|
||||
error = git_reference_lookup(&stash, repo, GIT_REFS_STASH_FILE);
|
||||
error = git_reference_lookup(&stash, repo, GIT_STASH_REF);
|
||||
if (error == GIT_ENOTFOUND) {
|
||||
git_error_clear();
|
||||
return 0;
|
||||
@@ -1196,7 +1196,7 @@ int git_stash_foreach(
|
||||
if (error < 0)
|
||||
goto cleanup;
|
||||
|
||||
if ((error = git_reflog_read(&reflog, repo, GIT_REFS_STASH_FILE)) < 0)
|
||||
if ((error = git_reflog_read(&reflog, repo, GIT_STASH_REF)) < 0)
|
||||
goto cleanup;
|
||||
|
||||
max = git_reflog_entrycount(reflog);
|
||||
@@ -1233,13 +1233,13 @@ int git_stash_drop(
|
||||
if ((error = git_transaction_new(&tx, repo)) < 0)
|
||||
return error;
|
||||
|
||||
if ((error = git_transaction_lock_ref(tx, GIT_REFS_STASH_FILE)) < 0)
|
||||
if ((error = git_transaction_lock_ref(tx, GIT_STASH_REF)) < 0)
|
||||
goto cleanup;
|
||||
|
||||
if ((error = git_reference_lookup(&stash, repo, GIT_REFS_STASH_FILE)) < 0)
|
||||
if ((error = git_reference_lookup(&stash, repo, GIT_STASH_REF)) < 0)
|
||||
goto cleanup;
|
||||
|
||||
if ((error = git_reflog_read(&reflog, repo, GIT_REFS_STASH_FILE)) < 0)
|
||||
if ((error = git_reflog_read(&reflog, repo, GIT_STASH_REF)) < 0)
|
||||
goto cleanup;
|
||||
|
||||
max = git_reflog_entrycount(reflog);
|
||||
@@ -1253,17 +1253,17 @@ int git_stash_drop(
|
||||
if ((error = git_reflog_drop(reflog, index, true)) < 0)
|
||||
goto cleanup;
|
||||
|
||||
if ((error = git_transaction_set_reflog(tx, GIT_REFS_STASH_FILE, reflog)) < 0)
|
||||
if ((error = git_transaction_set_reflog(tx, GIT_STASH_REF, reflog)) < 0)
|
||||
goto cleanup;
|
||||
|
||||
if (max == 1) {
|
||||
if ((error = git_transaction_remove(tx, GIT_REFS_STASH_FILE)) < 0)
|
||||
if ((error = git_transaction_remove(tx, GIT_STASH_REF)) < 0)
|
||||
goto cleanup;
|
||||
} else if (index == 0) {
|
||||
const git_reflog_entry *entry;
|
||||
|
||||
entry = git_reflog_entry_byindex(reflog, 0);
|
||||
if ((error = git_transaction_set_target(tx, GIT_REFS_STASH_FILE, &entry->oid_cur, NULL, NULL)) < 0)
|
||||
if ((error = git_transaction_set_target(tx, GIT_STASH_REF, &entry->oid_cur, NULL, NULL)) < 0)
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
|
||||
@@ -100,9 +100,9 @@ void test_stash_drop__dropping_an_entry_rewrites_reflog_history(void)
|
||||
|
||||
push_three_states();
|
||||
|
||||
cl_git_pass(git_reference_lookup(&stash, repo, GIT_REFS_STASH_FILE));
|
||||
cl_git_pass(git_reference_lookup(&stash, repo, GIT_STASH_REF));
|
||||
|
||||
cl_git_pass(git_reflog_read(&reflog, repo, GIT_REFS_STASH_FILE));
|
||||
cl_git_pass(git_reflog_read(&reflog, repo, GIT_STASH_REF));
|
||||
entry = git_reflog_entry_byindex(reflog, 1);
|
||||
|
||||
git_oid_cpy(&oid, git_reflog_entry_id_old(entry));
|
||||
@@ -112,7 +112,7 @@ void test_stash_drop__dropping_an_entry_rewrites_reflog_history(void)
|
||||
|
||||
cl_git_pass(git_stash_drop(repo, 1));
|
||||
|
||||
cl_git_pass(git_reflog_read(&reflog, repo, GIT_REFS_STASH_FILE));
|
||||
cl_git_pass(git_reflog_read(&reflog, repo, GIT_STASH_REF));
|
||||
entry = git_reflog_entry_byindex(reflog, 0);
|
||||
|
||||
cl_assert_equal_oid(&oid, git_reflog_entry_id_old(entry));
|
||||
@@ -129,7 +129,7 @@ void test_stash_drop__dropping_the_last_entry_removes_the_stash(void)
|
||||
|
||||
push_three_states();
|
||||
|
||||
cl_git_pass(git_reference_lookup(&stash, repo, GIT_REFS_STASH_FILE));
|
||||
cl_git_pass(git_reference_lookup(&stash, repo, GIT_STASH_REF));
|
||||
git_reference_free(stash);
|
||||
|
||||
cl_git_pass(git_stash_drop(repo, 0));
|
||||
@@ -137,7 +137,7 @@ void test_stash_drop__dropping_the_last_entry_removes_the_stash(void)
|
||||
cl_git_pass(git_stash_drop(repo, 0));
|
||||
|
||||
cl_git_fail_with(
|
||||
git_reference_lookup(&stash, repo, GIT_REFS_STASH_FILE), GIT_ENOTFOUND);
|
||||
git_reference_lookup(&stash, repo, GIT_STASH_REF), GIT_ENOTFOUND);
|
||||
}
|
||||
|
||||
static void retrieve_top_stash_id(git_oid *out)
|
||||
@@ -145,7 +145,7 @@ static void retrieve_top_stash_id(git_oid *out)
|
||||
git_object *top_stash;
|
||||
|
||||
cl_git_pass(git_revparse_single(&top_stash, repo, "stash@{0}"));
|
||||
cl_git_pass(git_reference_name_to_id(out, repo, GIT_REFS_STASH_FILE));
|
||||
cl_git_pass(git_reference_name_to_id(out, repo, GIT_STASH_REF));
|
||||
|
||||
cl_assert_equal_oid(out, git_object_id(top_stash));
|
||||
|
||||
|
||||
Reference in New Issue
Block a user