mirror of
https://git.proxmox.com/git/libgit2
synced 2025-05-21 10:17:20 +00:00
reference_rename: don't delete the reflog
reference_rename used to delete an old reflog file when renaming a reference to not confuse git.git. Don't do this anymore but let the user take care of writing a reflog entry. Signed-off-by: schu <schu-github@schulog.org>
This commit is contained in:
parent
b7c93a66e2
commit
a5cd086dff
@ -183,6 +183,11 @@ GIT_EXTERN(int) git_reference_set_oid(git_reference *ref, const git_oid *id);
|
|||||||
* If the `force` flag is not enabled, and there's already
|
* If the `force` flag is not enabled, and there's already
|
||||||
* a reference with the given name, the renaming will fail.
|
* a reference with the given name, the renaming will fail.
|
||||||
*
|
*
|
||||||
|
* IMPORTANT:
|
||||||
|
* The user needs to write a proper reflog entry if the
|
||||||
|
* reflog is enabled for the repository. We only rename
|
||||||
|
* the reflog if it exists.
|
||||||
|
*
|
||||||
* @param ref The reference to rename
|
* @param ref The reference to rename
|
||||||
* @param new_name The new name for the reference
|
* @param new_name The new name for the reference
|
||||||
* @param force Overwrite an existing reference
|
* @param force Overwrite an existing reference
|
||||||
|
31
src/refs.c
31
src/refs.c
@ -10,6 +10,7 @@
|
|||||||
#include "repository.h"
|
#include "repository.h"
|
||||||
#include "fileops.h"
|
#include "fileops.h"
|
||||||
#include "pack.h"
|
#include "pack.h"
|
||||||
|
#include "reflog.h"
|
||||||
|
|
||||||
#include <git2/tag.h>
|
#include <git2/tag.h>
|
||||||
#include <git2/object.h>
|
#include <git2/object.h>
|
||||||
@ -1318,28 +1319,6 @@ int git_reference_rename(git_reference *ref, const char *new_name, int force)
|
|||||||
} else goto rollback;
|
} else goto rollback;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* Crude hack: delete any logs till we support proper reflogs.
|
|
||||||
* Otherwise git.git will possibly fail and leave a mess. git.git
|
|
||||||
* writes reflogs by default in any repo with a working directory:
|
|
||||||
*
|
|
||||||
* "We only enable reflogs in repositories that have a working directory
|
|
||||||
* associated with them, as shared/bare repositories do not have
|
|
||||||
* an easy means to prune away old log entries, or may fail logging
|
|
||||||
* entirely if the user's gecos information is not valid during a push.
|
|
||||||
* This heuristic was suggested on the mailing list by Junio."
|
|
||||||
*
|
|
||||||
* Shawn O. Pearce - 0bee59186976b1d9e6b2dd77332480c9480131d5
|
|
||||||
*
|
|
||||||
* TODO
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
git_path_join_n(aux_path, 3, ref->owner->path_repository, "logs", ref->name);
|
|
||||||
if (git_futils_isfile(aux_path) == GIT_SUCCESS) {
|
|
||||||
if ((error = p_unlink(aux_path)) < GIT_SUCCESS)
|
|
||||||
goto rollback;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Finally we can create the new reference.
|
* Finally we can create the new reference.
|
||||||
*/
|
*/
|
||||||
@ -1371,6 +1350,14 @@ int git_reference_rename(git_reference *ref, const char *new_name, int force)
|
|||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Rename the reflog file.
|
||||||
|
*/
|
||||||
|
git_path_join_n(aux_path, 3, ref->owner->path_repository,
|
||||||
|
GIT_REFLOG_DIR, ref->name);
|
||||||
|
if (git_futils_exists(aux_path) == GIT_SUCCESS)
|
||||||
|
error = git_reflog_rename(ref, new_name);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Change the name of the reference given by the user.
|
* Change the name of the reference given by the user.
|
||||||
*/
|
*/
|
||||||
|
Loading…
Reference in New Issue
Block a user