* [PATCH 3/3] rename git_path() to git_path_unsafe()
From: Jonathan Nieder @ 2011-11-16 8:07 UTC (permalink / raw)
To: Ramkumar Ramachandra
Cc: Junio C Hamano, Git List, Nguyễn Thái Ngọc Duy
In-Reply-To: <20111116075955.GB13706@elie.hsd1.il.comcast.net>
git_path() stores its result to one of a rotating collection of four
static buffers. If more than 4 git_path() results are in play, the
result can be a little unpleasant, as each call clobbers the return
value from previous calls.
Therefore callers should be careful not to assign the return value
from git_path() to a long-lived variable. Rename the function to
git_path_unsafe() as a reminder.
Mechanics: This patch only makes three kinds of changes:
1) changing git_path(foo) to git_path_unsafe(foo)
2) changing xstrdup(git_path(foo)) to git_pathdup(foo)
3) rewrapping lines that were made longer by (1)
Suggested-by: Junio C Hamano <gitster@pobox.com>
Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
---
Documentation/technical/api-string-list.txt | 5 +-
attr.c | 2 +-
bisect.c | 8 ++--
branch.c | 12 +++---
builtin/add.c | 2 +-
builtin/commit.c | 57 ++++++++++++++-------------
builtin/config.c | 4 +-
builtin/fetch-pack.c | 4 +-
builtin/fetch.c | 5 +-
builtin/fsck.c | 2 +-
builtin/init-db.c | 12 +++---
builtin/merge.c | 32 +++++++-------
builtin/notes.c | 2 +-
builtin/remote.c | 6 +-
builtin/reset.c | 2 +-
builtin/revert.c | 18 ++++----
cache.h | 3 +-
contrib/examples/builtin-fetch--tool.c | 4 +-
dir.c | 2 +-
fast-import.c | 2 +-
http-backend.c | 2 +-
notes-merge.c | 22 ++++++-----
pack-refs.c | 6 +-
path.c | 2 +-
refs.c | 51 +++++++++++++-----------
remote.c | 4 +-
rerere.c | 12 +++---
run-command.c | 4 +-
sequencer.c | 6 +-
server-info.c | 2 +-
sha1_file.c | 4 +-
shallow.c | 2 +-
transport.c | 4 +-
unpack-trees.c | 2 +-
34 files changed, 160 insertions(+), 147 deletions(-)
diff --git a/Documentation/technical/api-string-list.txt b/Documentation/technical/api-string-list.txt
index ce24eb96..446a51ab 100644
--- a/Documentation/technical/api-string-list.txt
+++ b/Documentation/technical/api-string-list.txt
@@ -13,8 +13,9 @@ The caller:
. Initializes the members. You might want to set the flag `strdup_strings`
if the strings should be strdup()ed. For example, this is necessary
- when you add something like git_path("..."), since that function returns
- a static buffer that will change with the next call to git_path().
+ when you add something like git_path_unsafe("..."), since that function
+ returns a static buffer that will change with the next call to
+ git_path_unsafe().
+
If you need something advanced, you can manually malloc() the `items`
member (you need this if you add things later) and you should set the
diff --git a/attr.c b/attr.c
index 76b079f0..afdd6d24 100644
--- a/attr.c
+++ b/attr.c
@@ -529,7 +529,7 @@ static void bootstrap_attr_stack(void)
debug_push(elem);
}
- elem = read_attr_from_file(git_path(INFOATTRIBUTES_FILE), 1);
+ elem = read_attr_from_file(git_path_unsafe(INFOATTRIBUTES_FILE), 1);
if (!elem)
elem = xcalloc(1, sizeof(*elem));
elem->origin = NULL;
diff --git a/bisect.c b/bisect.c
index 6e186e29..315d22e6 100644
--- a/bisect.c
+++ b/bisect.c
@@ -422,7 +422,7 @@ static int read_bisect_refs(void)
static void read_bisect_paths(struct argv_array *array)
{
struct strbuf str = STRBUF_INIT;
- const char *filename = git_path("BISECT_NAMES");
+ const char *filename = git_path_unsafe("BISECT_NAMES");
FILE *fp = fopen(filename, "r");
if (!fp)
@@ -643,7 +643,7 @@ static void exit_if_skipped_commits(struct commit_list *tried,
static int is_expected_rev(const unsigned char *sha1)
{
- const char *filename = git_path("BISECT_EXPECTED_REV");
+ const char *filename = git_path_unsafe("BISECT_EXPECTED_REV");
struct stat st;
struct strbuf str = STRBUF_INIT;
FILE *fp;
@@ -668,7 +668,7 @@ static int is_expected_rev(const unsigned char *sha1)
static void mark_expected_rev(char *bisect_rev_hex)
{
int len = strlen(bisect_rev_hex);
- const char *filename = git_path("BISECT_EXPECTED_REV");
+ const char *filename = git_path_unsafe("BISECT_EXPECTED_REV");
int fd = open(filename, O_CREAT | O_TRUNC | O_WRONLY, 0600);
if (fd < 0)
@@ -833,7 +833,7 @@ static int check_ancestors(const char *prefix)
*/
static void check_good_are_ancestors_of_bad(const char *prefix, int no_checkout)
{
- const char *filename = git_path("BISECT_ANCESTORS_OK");
+ const char *filename = git_path_unsafe("BISECT_ANCESTORS_OK");
struct stat st;
int fd;
diff --git a/branch.c b/branch.c
index d8098762..5a3faa10 100644
--- a/branch.c
+++ b/branch.c
@@ -240,11 +240,11 @@ void create_branch(const char *head,
void remove_branch_state(void)
{
- unlink(git_path("CHERRY_PICK_HEAD"));
- unlink(git_path("MERGE_HEAD"));
- unlink(git_path("MERGE_RR"));
- unlink(git_path("MERGE_MSG"));
- unlink(git_path("MERGE_MODE"));
- unlink(git_path("SQUASH_MSG"));
+ unlink(git_path_unsafe("CHERRY_PICK_HEAD"));
+ unlink(git_path_unsafe("MERGE_HEAD"));
+ unlink(git_path_unsafe("MERGE_RR"));
+ unlink(git_path_unsafe("MERGE_MSG"));
+ unlink(git_path_unsafe("MERGE_MODE"));
+ unlink(git_path_unsafe("SQUASH_MSG"));
remove_sequencer_state(0);
}
diff --git a/builtin/add.c b/builtin/add.c
index c59b0c98..0aabb61d 100644
--- a/builtin/add.c
+++ b/builtin/add.c
@@ -259,7 +259,7 @@ int interactive_add(int argc, const char **argv, const char *prefix, int patch)
static int edit_patch(int argc, const char **argv, const char *prefix)
{
- char *file = xstrdup(git_path("ADD_EDIT.patch"));
+ char *file = git_pathdup("ADD_EDIT.patch");
const char *apply_argv[] = { "apply", "--recount", "--cached",
NULL, NULL };
struct child_process child;
diff --git a/builtin/commit.c b/builtin/commit.c
index c46f2d18..e9aa5e75 100644
--- a/builtin/commit.c
+++ b/builtin/commit.c
@@ -178,9 +178,9 @@ static struct option builtin_commit_options[] = {
static void determine_whence(struct wt_status *s)
{
- if (file_exists(git_path("MERGE_HEAD")))
+ if (file_exists(git_path_unsafe("MERGE_HEAD")))
whence = FROM_MERGE;
- else if (file_exists(git_path("CHERRY_PICK_HEAD")))
+ else if (file_exists(git_path_unsafe("CHERRY_PICK_HEAD")))
whence = FROM_CHERRY_PICK;
else
whence = FROM_COMMIT;
@@ -465,8 +465,8 @@ static char *prepare_index(int argc, const char **argv, const char *prefix,
die(_("unable to write new_index file"));
fd = hold_lock_file_for_update(&false_lock,
- git_path("next-index-%"PRIuMAX,
- (uintmax_t) getpid()),
+ git_path_unsafe("next-index-%"PRIuMAX,
+ (uintmax_t) getpid()),
LOCK_DIE_ON_ERROR);
create_base_index(current_head);
@@ -691,12 +691,12 @@ static int prepare_to_commit(const char *index_file, const char *prefix,
format_commit_message(commit, "fixup! %s\n\n",
&sb, &ctx);
hook_arg1 = "message";
- } else if (!stat(git_path("MERGE_MSG"), &statbuf)) {
- if (strbuf_read_file(&sb, git_path("MERGE_MSG"), 0) < 0)
+ } else if (!stat(git_path_unsafe("MERGE_MSG"), &statbuf)) {
+ if (strbuf_read_file(&sb, git_path_unsafe("MERGE_MSG"), 0) < 0)
die_errno(_("could not read MERGE_MSG"));
hook_arg1 = "merge";
- } else if (!stat(git_path("SQUASH_MSG"), &statbuf)) {
- if (strbuf_read_file(&sb, git_path("SQUASH_MSG"), 0) < 0)
+ } else if (!stat(git_path_unsafe("SQUASH_MSG"), &statbuf)) {
+ if (strbuf_read_file(&sb, git_path_unsafe("SQUASH_MSG"), 0) < 0)
die_errno(_("could not read SQUASH_MSG"));
hook_arg1 = "squash";
} else if (template_file) {
@@ -727,9 +727,10 @@ static int prepare_to_commit(const char *index_file, const char *prefix,
hook_arg2 = "";
}
- s->fp = fopen(git_path(commit_editmsg), "w");
+ s->fp = fopen(git_path_unsafe(commit_editmsg), "w");
if (s->fp == NULL)
- die_errno(_("could not open '%s'"), git_path(commit_editmsg));
+ die_errno(_("could not open '%s'"),
+ git_path_unsafe(commit_editmsg));
if (clean_message_contents)
stripspace(&sb, 0);
@@ -773,7 +774,7 @@ static int prepare_to_commit(const char *index_file, const char *prefix,
"and try again.\n"
""),
whence_s(),
- git_path(whence == FROM_MERGE
+ git_path_unsafe(whence == FROM_MERGE
? "MERGE_HEAD"
: "CHERRY_PICK_HEAD"));
@@ -870,8 +871,9 @@ static int prepare_to_commit(const char *index_file, const char *prefix,
return 0;
}
- if (run_hook(index_file, "prepare-commit-msg",
- git_path(commit_editmsg), hook_arg1, hook_arg2, NULL))
+ if (run_hook(index_file,
+ "prepare-commit-msg", git_path_unsafe(commit_editmsg),
+ hook_arg1, hook_arg2, NULL))
return 0;
if (use_editor) {
@@ -879,7 +881,7 @@ static int prepare_to_commit(const char *index_file, const char *prefix,
const char *env[2] = { NULL };
env[0] = index;
snprintf(index, sizeof(index), "GIT_INDEX_FILE=%s", index_file);
- if (launch_editor(git_path(commit_editmsg), NULL, env)) {
+ if (launch_editor(git_path_unsafe(commit_editmsg), NULL, env)) {
fprintf(stderr,
_("Please supply the message using either -m or -F option.\n"));
exit(1);
@@ -887,7 +889,8 @@ static int prepare_to_commit(const char *index_file, const char *prefix,
}
if (!no_verify &&
- run_hook(index_file, "commit-msg", git_path(commit_editmsg), NULL)) {
+ run_hook(index_file,
+ "commit-msg", git_path_unsafe(commit_editmsg), NULL)) {
return 0;
}
@@ -1347,10 +1350,10 @@ static int run_rewrite_hook(const unsigned char *oldsha1,
int code;
size_t n;
- if (access(git_path(post_rewrite_hook), X_OK) < 0)
+ if (access(git_path_unsafe(post_rewrite_hook), X_OK) < 0)
return 0;
- argv[0] = git_path(post_rewrite_hook);
+ argv[0] = git_path_unsafe(post_rewrite_hook);
argv[1] = "amend";
argv[2] = NULL;
@@ -1431,10 +1434,10 @@ int cmd_commit(int argc, const char **argv, const char *prefix)
if (!reflog_msg)
reflog_msg = "commit (merge)";
pptr = &commit_list_insert(current_head, pptr)->next;
- fp = fopen(git_path("MERGE_HEAD"), "r");
+ fp = fopen(git_path_unsafe("MERGE_HEAD"), "r");
if (fp == NULL)
die_errno(_("could not open '%s' for reading"),
- git_path("MERGE_HEAD"));
+ git_path_unsafe("MERGE_HEAD"));
while (strbuf_getline(&m, fp, '\n') != EOF) {
unsigned char sha1[20];
if (get_sha1_hex(m.buf, sha1) < 0)
@@ -1444,8 +1447,8 @@ int cmd_commit(int argc, const char **argv, const char *prefix)
}
fclose(fp);
strbuf_release(&m);
- if (!stat(git_path("MERGE_MODE"), &statbuf)) {
- if (strbuf_read_file(&sb, git_path("MERGE_MODE"), 0) < 0)
+ if (!stat(git_path_unsafe("MERGE_MODE"), &statbuf)) {
+ if (strbuf_read_file(&sb, git_path_unsafe("MERGE_MODE"), 0) < 0)
die_errno(_("could not read MERGE_MODE"));
if (!strcmp(sb.buf, "no-ff"))
allow_fast_forward = 0;
@@ -1462,7 +1465,7 @@ int cmd_commit(int argc, const char **argv, const char *prefix)
/* Finally, get the commit message */
strbuf_reset(&sb);
- if (strbuf_read_file(&sb, git_path(commit_editmsg), 0) < 0) {
+ if (strbuf_read_file(&sb, git_path_unsafe(commit_editmsg), 0) < 0) {
int saved_errno = errno;
rollback_index_files();
die(_("could not read commit message: %s"), strerror(saved_errno));
@@ -1513,11 +1516,11 @@ int cmd_commit(int argc, const char **argv, const char *prefix)
die(_("cannot update HEAD ref"));
}
- unlink(git_path("CHERRY_PICK_HEAD"));
- unlink(git_path("MERGE_HEAD"));
- unlink(git_path("MERGE_MSG"));
- unlink(git_path("MERGE_MODE"));
- unlink(git_path("SQUASH_MSG"));
+ unlink(git_path_unsafe("CHERRY_PICK_HEAD"));
+ unlink(git_path_unsafe("MERGE_HEAD"));
+ unlink(git_path_unsafe("MERGE_MSG"));
+ unlink(git_path_unsafe("MERGE_MODE"));
+ unlink(git_path_unsafe("SQUASH_MSG"));
if (commit_index_files())
die (_("Repository has been updated, but unable to write\n"
diff --git a/builtin/config.c b/builtin/config.c
index 0315ad76..407d7ca8 100644
--- a/builtin/config.c
+++ b/builtin/config.c
@@ -434,8 +434,8 @@ int cmd_config(int argc, const char **argv, const char *prefix)
die("not in a git directory");
git_config(git_default_config, NULL);
launch_editor(config_exclusive_filename ?
- config_exclusive_filename : git_path("config"),
- NULL, NULL);
+ config_exclusive_filename :
+ git_path_unsafe("config"), NULL, NULL);
}
else if (actions == ACTION_SET) {
int ret;
diff --git a/builtin/fetch-pack.c b/builtin/fetch-pack.c
index c6bc8eb0..f8d0954c 100644
--- a/builtin/fetch-pack.c
+++ b/builtin/fetch-pack.c
@@ -1026,7 +1026,7 @@ struct ref *fetch_pack(struct fetch_pack_args *my_args,
if (&args != my_args)
memcpy(&args, my_args, sizeof(args));
if (args.depth > 0) {
- if (stat(git_path("shallow"), &st))
+ if (stat(git_path_unsafe("shallow"), &st))
st.st_mtime = 0;
}
@@ -1041,7 +1041,7 @@ struct ref *fetch_pack(struct fetch_pack_args *my_args,
if (args.depth > 0) {
struct cache_time mtime;
struct strbuf sb = STRBUF_INIT;
- char *shallow = git_path("shallow");
+ char *shallow = git_path_unsafe("shallow");
int fd;
mtime.sec = st.st_mtime;
diff --git a/builtin/fetch.c b/builtin/fetch.c
index 91731b90..ccbe63c7 100644
--- a/builtin/fetch.c
+++ b/builtin/fetch.c
@@ -367,7 +367,8 @@ static int store_updated_refs(const char *raw_url, const char *remote_name,
char note[1024];
const char *what, *kind;
struct ref *rm;
- char *url, *filename = dry_run ? "/dev/null" : git_path("FETCH_HEAD");
+ char *url;
+ char *filename = dry_run ? "/dev/null" : git_path_unsafe("FETCH_HEAD");
fp = fopen(filename, "a");
if (!fp)
@@ -647,7 +648,7 @@ static void check_not_current_branch(struct ref *ref_map)
static int truncate_fetch_head(void)
{
- char *filename = git_path("FETCH_HEAD");
+ char *filename = git_path_unsafe("FETCH_HEAD");
FILE *fp = fopen(filename, "w");
if (!fp)
diff --git a/builtin/fsck.c b/builtin/fsck.c
index df1a88b5..f8429f55 100644
--- a/builtin/fsck.c
+++ b/builtin/fsck.c
@@ -215,7 +215,7 @@ static void check_unreachable_object(struct object *obj)
printf("dangling %s %s\n", typename(obj->type),
sha1_to_hex(obj->sha1));
if (write_lost_and_found) {
- char *filename = git_path("lost-found/%s/%s",
+ char *filename = git_path_unsafe("lost-found/%s/%s",
obj->type == OBJ_COMMIT ? "commit" : "other",
sha1_to_hex(obj->sha1));
FILE *f;
diff --git a/builtin/init-db.c b/builtin/init-db.c
index d07554c8..7ae89f85 100644
--- a/builtin/init-db.c
+++ b/builtin/init-db.c
@@ -198,9 +198,9 @@ static int create_default_files(const char *template_path)
/*
* Create .git/refs/{heads,tags}
*/
- safe_create_dir(git_path("refs"), 1);
- safe_create_dir(git_path("refs/heads"), 1);
- safe_create_dir(git_path("refs/tags"), 1);
+ safe_create_dir(git_path_unsafe("refs"), 1);
+ safe_create_dir(git_path_unsafe("refs/heads"), 1);
+ safe_create_dir(git_path_unsafe("refs/tags"), 1);
/* Just look for `init.templatedir` */
git_config(git_init_db_config, NULL);
@@ -224,9 +224,9 @@ static int create_default_files(const char *template_path)
*/
if (shared_repository) {
adjust_shared_perm(get_git_dir());
- adjust_shared_perm(git_path("refs"));
- adjust_shared_perm(git_path("refs/heads"));
- adjust_shared_perm(git_path("refs/tags"));
+ adjust_shared_perm(git_path_unsafe("refs"));
+ adjust_shared_perm(git_path_unsafe("refs/heads"));
+ adjust_shared_perm(git_path_unsafe("refs/tags"));
}
/*
diff --git a/builtin/merge.c b/builtin/merge.c
index 2870a6af..3e75c30b 100644
--- a/builtin/merge.c
+++ b/builtin/merge.c
@@ -213,9 +213,9 @@ static struct option builtin_merge_options[] = {
/* Cleans up metadata that is uninteresting after a succeeded merge. */
static void drop_save(void)
{
- unlink(git_path("MERGE_HEAD"));
- unlink(git_path("MERGE_MSG"));
- unlink(git_path("MERGE_MODE"));
+ unlink(git_path_unsafe("MERGE_HEAD"));
+ unlink(git_path_unsafe("MERGE_MSG"));
+ unlink(git_path_unsafe("MERGE_MODE"));
}
static int save_state(unsigned char *stash)
@@ -321,7 +321,7 @@ static void squash_message(struct commit *commit)
struct pretty_print_context ctx = {0};
printf(_("Squash commit -- not updating HEAD\n"));
- filename = git_path("SQUASH_MSG");
+ filename = git_path_unsafe("SQUASH_MSG");
fd = open(filename, O_WRONLY | O_CREAT, 0666);
if (fd < 0)
die_errno(_("Could not write to '%s'"), filename);
@@ -493,13 +493,13 @@ static void merge_name(const char *remote, struct strbuf *msg)
}
if (!strcmp(remote, "FETCH_HEAD") &&
- !access(git_path("FETCH_HEAD"), R_OK)) {
+ !access(git_path_unsafe("FETCH_HEAD"), R_OK)) {
const char *filename;
FILE *fp;
struct strbuf line = STRBUF_INIT;
char *ptr;
- filename = git_path("FETCH_HEAD");
+ filename = git_path_unsafe("FETCH_HEAD");
fp = fopen(filename, "r");
if (!fp)
die_errno(_("could not open '%s' for reading"),
@@ -851,7 +851,7 @@ static void add_strategies(const char *string, unsigned attr)
static void write_merge_msg(struct strbuf *msg)
{
- const char *filename = git_path("MERGE_MSG");
+ const char *filename = git_path_unsafe("MERGE_MSG");
int fd = open(filename, O_WRONLY | O_CREAT, 0666);
if (fd < 0)
die_errno(_("Could not open '%s' for writing"),
@@ -863,7 +863,7 @@ static void write_merge_msg(struct strbuf *msg)
static void read_merge_msg(struct strbuf *msg)
{
- const char *filename = git_path("MERGE_MSG");
+ const char *filename = git_path_unsafe("MERGE_MSG");
strbuf_reset(msg);
if (strbuf_read_file(msg, filename, 0) < 0)
die_errno(_("Could not read from '%s'"), filename);
@@ -887,9 +887,9 @@ static void prepare_to_commit(void)
strbuf_addch(&msg, '\n');
write_merge_msg(&msg);
run_hook(get_index_file(), "prepare-commit-msg",
- git_path("MERGE_MSG"), "merge", NULL, NULL);
+ git_path_unsafe("MERGE_MSG"), "merge", NULL, NULL);
if (option_edit) {
- if (launch_editor(git_path("MERGE_MSG"), NULL, NULL))
+ if (launch_editor(git_path_unsafe("MERGE_MSG"), NULL, NULL))
abort_commit(NULL);
}
read_merge_msg(&msg);
@@ -958,7 +958,7 @@ static int suggest_conflicts(int renormalizing)
FILE *fp;
int pos;
- filename = git_path("MERGE_MSG");
+ filename = git_path_unsafe("MERGE_MSG");
fp = fopen(filename, "a");
if (!fp)
die_errno(_("Could not open '%s' for writing"), filename);
@@ -1061,7 +1061,7 @@ static void write_merge_state(void)
for (j = remoteheads; j; j = j->next)
strbuf_addf(&buf, "%s\n",
sha1_to_hex(j->item->object.sha1));
- filename = git_path("MERGE_HEAD");
+ filename = git_path_unsafe("MERGE_HEAD");
fd = open(filename, O_WRONLY | O_CREAT, 0666);
if (fd < 0)
die_errno(_("Could not open '%s' for writing"), filename);
@@ -1071,7 +1071,7 @@ static void write_merge_state(void)
strbuf_addch(&merge_msg, '\n');
write_merge_msg(&merge_msg);
- filename = git_path("MERGE_MODE");
+ filename = git_path_unsafe("MERGE_MODE");
fd = open(filename, O_WRONLY | O_CREAT | O_TRUNC, 0666);
if (fd < 0)
die_errno(_("Could not open '%s' for writing"), filename);
@@ -1126,7 +1126,7 @@ int cmd_merge(int argc, const char **argv, const char *prefix)
int nargc = 2;
const char *nargv[] = {"reset", "--merge", NULL};
- if (!file_exists(git_path("MERGE_HEAD")))
+ if (!file_exists(git_path_unsafe("MERGE_HEAD")))
die(_("There is no merge to abort (MERGE_HEAD missing)."));
/* Invoke 'git reset --merge' */
@@ -1136,7 +1136,7 @@ int cmd_merge(int argc, const char **argv, const char *prefix)
if (read_cache_unmerged())
die_resolve_conflict("merge");
- if (file_exists(git_path("MERGE_HEAD"))) {
+ if (file_exists(git_path_unsafe("MERGE_HEAD"))) {
/*
* There is no unmerged entry, don't advise 'git
* add/rm <file>', just 'git commit'.
@@ -1147,7 +1147,7 @@ int cmd_merge(int argc, const char **argv, const char *prefix)
else
die(_("You have not concluded your merge (MERGE_HEAD exists)."));
}
- if (file_exists(git_path("CHERRY_PICK_HEAD"))) {
+ if (file_exists(git_path_unsafe("CHERRY_PICK_HEAD"))) {
if (advice_resolve_conflict)
die(_("You have not concluded your cherry-pick (CHERRY_PICK_HEAD exists).\n"
"Please, commit your changes before you can merge."));
diff --git a/builtin/notes.c b/builtin/notes.c
index f8e437db..c037afe6 100644
--- a/builtin/notes.c
+++ b/builtin/notes.c
@@ -944,7 +944,7 @@ static int merge(int argc, const char **argv, const char *prefix)
printf("Automatic notes merge failed. Fix conflicts in %s and "
"commit the result with 'git notes merge --commit', or "
"abort the merge with 'git notes merge --abort'.\n",
- git_path(NOTES_MERGE_WORKTREE));
+ git_path_unsafe(NOTES_MERGE_WORKTREE));
}
free_notes(t);
diff --git a/builtin/remote.c b/builtin/remote.c
index c8106438..c7032125 100644
--- a/builtin/remote.c
+++ b/builtin/remote.c
@@ -546,7 +546,7 @@ static int add_branch_for_removal(const char *refname,
/* make sure that symrefs are deleted */
if (flags & REF_ISSYMREF)
- return unlink(git_path("%s", refname));
+ return unlink(git_path_unsafe("%s", refname));
item = string_list_append(branches->branches, refname);
item->util = xmalloc(20);
@@ -608,9 +608,9 @@ static int migrate_file(struct remote *remote)
return error("Could not append '%s' to '%s'",
remote->fetch_refspec[i], buf.buf);
if (remote->origin == REMOTE_REMOTES)
- path = git_path("remotes/%s", remote->name);
+ path = git_path_unsafe("remotes/%s", remote->name);
else if (remote->origin == REMOTE_BRANCHES)
- path = git_path("branches/%s", remote->name);
+ path = git_path_unsafe("branches/%s", remote->name);
if (path)
unlink_or_warn(path);
return 0;
diff --git a/builtin/reset.c b/builtin/reset.c
index 811e8e25..18bacdac 100644
--- a/builtin/reset.c
+++ b/builtin/reset.c
@@ -35,7 +35,7 @@ static const char *reset_type_names[] = {
static inline int is_merge(void)
{
- return !access(git_path("MERGE_HEAD"), F_OK);
+ return !access(git_path_unsafe("MERGE_HEAD"), F_OK);
}
static int reset_index_file(const unsigned char *sha1, int reset_type, int quiet)
diff --git a/builtin/revert.c b/builtin/revert.c
index 985f95b0..09a062c6 100644
--- a/builtin/revert.c
+++ b/builtin/revert.c
@@ -294,7 +294,7 @@ static void write_cherry_pick_head(struct commit *commit)
strbuf_addf(&buf, "%s\n", sha1_to_hex(commit->object.sha1));
- filename = git_path("CHERRY_PICK_HEAD");
+ filename = git_path_unsafe("CHERRY_PICK_HEAD");
fd = open(filename, O_WRONLY | O_CREAT, 0666);
if (fd < 0)
die_errno(_("Could not open '%s' for writing"), filename);
@@ -314,7 +314,7 @@ static void print_advice(int show_hint)
* (typically rebase --interactive) wants to take care
* of the commit itself so remove CHERRY_PICK_HEAD
*/
- unlink(git_path("CHERRY_PICK_HEAD"));
+ unlink(git_path_unsafe("CHERRY_PICK_HEAD"));
return;
}
@@ -762,7 +762,7 @@ static int parse_insn_buffer(char *buf, struct commit_list **todo_list,
static void read_populate_todo(struct commit_list **todo_list,
struct replay_opts *opts)
{
- const char *todo_file = git_path(SEQ_TODO_FILE);
+ const char *todo_file = git_path_unsafe(SEQ_TODO_FILE);
struct strbuf buf = STRBUF_INIT;
int fd, res;
@@ -817,7 +817,7 @@ static int populate_opts_cb(const char *key, const char *value, void *data)
static void read_populate_opts(struct replay_opts **opts_ptr)
{
- const char *opts_file = git_path(SEQ_OPTS_FILE);
+ const char *opts_file = git_path_unsafe(SEQ_OPTS_FILE);
if (!file_exists(opts_file))
return;
@@ -841,7 +841,7 @@ static void walk_revs_populate_todo(struct commit_list **todo_list,
static int create_seq_dir(void)
{
- const char *seq_dir = git_path(SEQ_DIR);
+ const char *seq_dir = git_path_unsafe(SEQ_DIR);
if (file_exists(seq_dir))
return error(_("%s already exists."), seq_dir);
@@ -852,7 +852,7 @@ static int create_seq_dir(void)
static void save_head(const char *head)
{
- const char *head_file = git_path(SEQ_HEAD_FILE);
+ const char *head_file = git_path_unsafe(SEQ_HEAD_FILE);
static struct lock_file head_lock;
struct strbuf buf = STRBUF_INIT;
int fd;
@@ -867,7 +867,7 @@ static void save_head(const char *head)
static void save_todo(struct commit_list *todo_list, struct replay_opts *opts)
{
- const char *todo_file = git_path(SEQ_TODO_FILE);
+ const char *todo_file = git_path_unsafe(SEQ_TODO_FILE);
static struct lock_file todo_lock;
struct strbuf buf = STRBUF_INIT;
int fd;
@@ -888,7 +888,7 @@ static void save_todo(struct commit_list *todo_list, struct replay_opts *opts)
static void save_opts(struct replay_opts *opts)
{
- const char *opts_file = git_path(SEQ_OPTS_FILE);
+ const char *opts_file = git_path_unsafe(SEQ_OPTS_FILE);
if (opts->no_commit)
git_config_set_in_file(opts_file, "options.no-commit", "true");
@@ -969,7 +969,7 @@ static int pick_revisions(struct replay_opts *opts)
remove_sequencer_state(1);
return 0;
} else if (opts->subcommand == REPLAY_CONTINUE) {
- if (!file_exists(git_path(SEQ_TODO_FILE)))
+ if (!file_exists(git_path_unsafe(SEQ_TODO_FILE)))
goto error;
read_populate_opts(&opts);
read_populate_todo(&todo_list, opts);
diff --git a/cache.h b/cache.h
index 2e6ad360..7fb85445 100644
--- a/cache.h
+++ b/cache.h
@@ -662,7 +662,8 @@ extern char *git_pathdup(const char *fmt, ...)
/* Return a statically allocated filename matching the sha1 signature */
extern char *mkpath(const char *fmt, ...) __attribute__((format (printf, 1, 2)));
-extern char *git_path(const char *fmt, ...) __attribute__((format (printf, 1, 2)));
+extern char *git_path_unsafe(const char *fmt, ...)
+ __attribute__((format (printf, 1, 2)));
extern char *git_path_submodule(const char *path, const char *fmt, ...)
__attribute__((format (printf, 2, 3)));
diff --git a/contrib/examples/builtin-fetch--tool.c b/contrib/examples/builtin-fetch--tool.c
index 3140e405..ea18fdac 100644
--- a/contrib/examples/builtin-fetch--tool.c
+++ b/contrib/examples/builtin-fetch--tool.c
@@ -515,7 +515,7 @@ int cmd_fetch__tool(int argc, const char **argv, const char *prefix)
if (argc != 8)
return error("append-fetch-head takes 6 args");
- filename = git_path("FETCH_HEAD");
+ filename = git_path_unsafe("FETCH_HEAD");
fp = fopen(filename, "a");
if (!fp)
return error("cannot open %s: %s\n", filename, strerror(errno));
@@ -533,7 +533,7 @@ int cmd_fetch__tool(int argc, const char **argv, const char *prefix)
if (argc != 5)
return error("fetch-native-store takes 3 args");
- filename = git_path("FETCH_HEAD");
+ filename = git_path_unsafe("FETCH_HEAD");
fp = fopen(filename, "a");
if (!fp)
return error("cannot open %s: %s\n", filename, strerror(errno));
diff --git a/dir.c b/dir.c
index 6c0d7825..94662509 100644
--- a/dir.c
+++ b/dir.c
@@ -1224,7 +1224,7 @@ void setup_standard_excludes(struct dir_struct *dir)
const char *path;
dir->exclude_per_dir = ".gitignore";
- path = git_path("info/exclude");
+ path = git_path_unsafe("info/exclude");
if (!access(path, R_OK))
add_excludes_from_file(dir, path);
if (excludes_file && !access(excludes_file, R_OK))
diff --git a/fast-import.c b/fast-import.c
index 8d8ea3c4..04bcd353 100644
--- a/fast-import.c
+++ b/fast-import.c
@@ -403,7 +403,7 @@ static void dump_marks_helper(FILE *, uintmax_t, struct mark_set *);
static void write_crash_report(const char *err)
{
- char *loc = git_path("fast_import_crash_%"PRIuMAX, (uintmax_t) getpid());
+ char *loc = git_path_unsafe("fast_import_crash_%"PRIuMAX, (uintmax_t) getpid());
FILE *rpt = fopen(loc, "w");
struct branch *b;
unsigned long lu;
diff --git a/http-backend.c b/http-backend.c
index 59ad7da6..7169e040 100644
--- a/http-backend.c
+++ b/http-backend.c
@@ -161,7 +161,7 @@ static void send_strbuf(const char *type, struct strbuf *buf)
static void send_local_file(const char *the_type, const char *name)
{
- const char *p = git_path("%s", name);
+ const char *p = git_path_unsafe("%s", name);
size_t buf_alloc = 8192;
char *buf = xmalloc(buf_alloc);
int fd;
diff --git a/notes-merge.c b/notes-merge.c
index e9e41993..0b49e8ad 100644
--- a/notes-merge.c
+++ b/notes-merge.c
@@ -275,35 +275,37 @@ static void check_notes_merge_worktree(struct notes_merge_options *o)
* Must establish NOTES_MERGE_WORKTREE.
* Abort if NOTES_MERGE_WORKTREE already exists
*/
- if (file_exists(git_path(NOTES_MERGE_WORKTREE))) {
+ if (file_exists(git_path_unsafe(NOTES_MERGE_WORKTREE))) {
if (advice_resolve_conflict)
die("You have not concluded your previous "
"notes merge (%s exists).\nPlease, use "
"'git notes merge --commit' or 'git notes "
"merge --abort' to commit/abort the "
"previous merge before you start a new "
- "notes merge.", git_path("NOTES_MERGE_*"));
+ "notes merge.",
+ git_path_unsafe("NOTES_MERGE_*"));
else
die("You have not concluded your notes merge "
- "(%s exists).", git_path("NOTES_MERGE_*"));
+ "(%s exists).",
+ git_path_unsafe("NOTES_MERGE_*"));
}
- if (safe_create_leading_directories(git_path(
+ if (safe_create_leading_directories(git_path_unsafe(
NOTES_MERGE_WORKTREE "/.test")))
die_errno("unable to create directory %s",
- git_path(NOTES_MERGE_WORKTREE));
+ git_path_unsafe(NOTES_MERGE_WORKTREE));
o->has_worktree = 1;
- } else if (!file_exists(git_path(NOTES_MERGE_WORKTREE)))
+ } else if (!file_exists(git_path_unsafe(NOTES_MERGE_WORKTREE)))
/* NOTES_MERGE_WORKTREE should already be established */
die("missing '%s'. This should not happen",
- git_path(NOTES_MERGE_WORKTREE));
+ git_path_unsafe(NOTES_MERGE_WORKTREE));
}
static void write_buf_to_worktree(const unsigned char *obj,
const char *buf, unsigned long size)
{
int fd;
- char *path = git_path(NOTES_MERGE_WORKTREE "/%s", sha1_to_hex(obj));
+ char *path = git_path_unsafe(NOTES_MERGE_WORKTREE "/%s", sha1_to_hex(obj));
if (safe_create_leading_directories(path))
die_errno("unable to create directory for '%s'", path);
if (file_exists(path))
@@ -681,7 +683,7 @@ int notes_merge_commit(struct notes_merge_options *o,
* Finally store the new commit object SHA1 into 'result_sha1'.
*/
struct dir_struct dir;
- char *path = xstrdup(git_path(NOTES_MERGE_WORKTREE "/"));
+ char *path = git_pathdup(NOTES_MERGE_WORKTREE "/");
int path_len = strlen(path), i;
const char *msg = strstr(partial_commit->buffer, "\n\n");
@@ -731,7 +733,7 @@ int notes_merge_abort(struct notes_merge_options *o)
struct strbuf buf = STRBUF_INIT;
int ret;
- strbuf_addstr(&buf, git_path(NOTES_MERGE_WORKTREE));
+ strbuf_addstr(&buf, git_path_unsafe(NOTES_MERGE_WORKTREE));
OUTPUT(o, 3, "Removing notes merge worktree at %s", buf.buf);
ret = remove_dir_recursively(&buf, 0);
strbuf_release(&buf);
diff --git a/pack-refs.c b/pack-refs.c
index 23bbd00e..9557b063 100644
--- a/pack-refs.c
+++ b/pack-refs.c
@@ -86,7 +86,7 @@ static void try_remove_empty_parents(char *name)
if (q == p)
break;
*q = '\0';
- if (rmdir(git_path("%s", name)))
+ if (rmdir(git_path_unsafe("%s", name)))
break;
}
}
@@ -97,7 +97,7 @@ static void prune_ref(struct ref_to_prune *r)
struct ref_lock *lock = lock_ref_sha1(r->name + 5, r->sha1);
if (lock) {
- unlink_or_warn(git_path("%s", r->name));
+ unlink_or_warn(git_path_unsafe("%s", r->name));
unlock_ref(lock);
try_remove_empty_parents(r->name);
}
@@ -121,7 +121,7 @@ int pack_refs(unsigned int flags)
memset(&cbdata, 0, sizeof(cbdata));
cbdata.flags = flags;
- fd = hold_lock_file_for_update(&packed, git_path("packed-refs"),
+ fd = hold_lock_file_for_update(&packed, git_path_unsafe("packed-refs"),
LOCK_DIE_ON_ERROR);
cbdata.refs_file = fdopen(fd, "w");
if (!cbdata.refs_file)
diff --git a/path.c b/path.c
index b6f71d10..0611b7be 100644
--- a/path.c
+++ b/path.c
@@ -101,7 +101,7 @@ char *mkpath(const char *fmt, ...)
return cleanup_path(pathname);
}
-char *git_path(const char *fmt, ...)
+char *git_path_unsafe(const char *fmt, ...)
{
const char *git_dir = get_git_dir();
char *pathname = get_pathname();
diff --git a/refs.c b/refs.c
index e69ba26b..e527c7b7 100644
--- a/refs.c
+++ b/refs.c
@@ -268,7 +268,7 @@ static struct ref_array *get_packed_refs(const char *submodule)
if (submodule)
packed_refs_file = git_path_submodule(submodule, "packed-refs");
else
- packed_refs_file = git_path("packed-refs");
+ packed_refs_file = git_path_unsafe("packed-refs");
f = fopen(packed_refs_file, "r");
if (f) {
read_packed_refs(f, &refs->packed);
@@ -288,7 +288,7 @@ static void get_ref_dir(const char *submodule, const char *base,
if (submodule)
path = git_path_submodule(submodule, "%s", base);
else
- path = git_path("%s", base);
+ path = git_path_unsafe("%s", base);
dir = opendir(path);
@@ -319,7 +319,7 @@ static void get_ref_dir(const char *submodule, const char *base,
memcpy(ref + baselen, de->d_name, namelen+1);
refdir = submodule
? git_path_submodule(submodule, "%s", ref)
- : git_path("%s", ref);
+ : git_path_unsafe("%s", ref);
if (stat(refdir, &st) < 0)
continue;
if (S_ISDIR(st.st_mode)) {
@@ -1146,11 +1146,11 @@ int dwim_log(const char *str, int len, unsigned char *sha1, char **log)
ref = resolve_ref(path, hash, 1, NULL);
if (!ref)
continue;
- if (!stat(git_path("logs/%s", path), &st) &&
+ if (!stat(git_path_unsafe("logs/%s", path), &st) &&
S_ISREG(st.st_mode))
it = path;
else if (strcmp(ref, path) &&
- !stat(git_path("logs/%s", ref), &st) &&
+ !stat(git_path_unsafe("logs/%s", ref), &st) &&
S_ISREG(st.st_mode))
it = ref;
else
@@ -1186,7 +1186,7 @@ static struct ref_lock *lock_ref_sha1_basic(const char *ref, const unsigned char
* it is normal for the empty directory 'foo'
* to remain.
*/
- ref_file = git_path("%s", orig_ref);
+ ref_file = git_path_unsafe("%s", orig_ref);
if (remove_empty_directories(ref_file)) {
last_errno = errno;
error("there are still refs under '%s'", orig_ref);
@@ -1223,7 +1223,7 @@ static struct ref_lock *lock_ref_sha1_basic(const char *ref, const unsigned char
}
lock->ref_name = xstrdup(ref);
lock->orig_ref_name = xstrdup(orig_ref);
- ref_file = git_path("%s", ref);
+ ref_file = git_path_unsafe("%s", ref);
if (missing)
lock->force_write = 1;
if ((flags & REF_NODEREF) && (type & REF_ISSYMREF))
@@ -1272,9 +1272,10 @@ static int repack_without_ref(const char *refname)
ref = search_ref_array(packed, refname);
if (ref == NULL)
return 0;
- fd = hold_lock_file_for_update(&packlock, git_path("packed-refs"), 0);
+ fd = hold_lock_file_for_update(&packlock,
+ git_path_unsafe("packed-refs"), 0);
if (fd < 0) {
- unable_to_lock_error(git_path("packed-refs"), errno);
+ unable_to_lock_error(git_path_unsafe("packed-refs"), errno);
return error("cannot delete '%s' from packed refs", refname);
}
@@ -1313,7 +1314,7 @@ int delete_ref(const char *refname, const unsigned char *sha1, int delopt)
lock->lk->filename[i] = 0;
path = lock->lk->filename;
} else {
- path = git_path("%s", refname);
+ path = git_path_unsafe("%s", refname);
}
err = unlink_or_warn(path);
if (err && errno != ENOENT)
@@ -1328,7 +1329,7 @@ int delete_ref(const char *refname, const unsigned char *sha1, int delopt)
*/
ret |= repack_without_ref(refname);
- unlink_or_warn(git_path("logs/%s", lock->ref_name));
+ unlink_or_warn(git_path_unsafe("logs/%s", lock->ref_name));
invalidate_ref_cache(NULL);
unlock_ref(lock);
return ret;
@@ -1349,7 +1350,7 @@ int rename_ref(const char *oldref, const char *newref, const char *logmsg)
int flag = 0, logmoved = 0;
struct ref_lock *lock;
struct stat loginfo;
- int log = !lstat(git_path("logs/%s", oldref), &loginfo);
+ int log = !lstat(git_path_unsafe("logs/%s", oldref), &loginfo);
const char *symref = NULL;
if (log && S_ISLNK(loginfo.st_mode))
@@ -1368,7 +1369,8 @@ int rename_ref(const char *oldref, const char *newref, const char *logmsg)
if (!is_refname_available(newref, oldref, get_loose_refs(NULL), 0))
return 1;
- if (log && rename(git_path("logs/%s", oldref), git_path(TMP_RENAMED_LOG)))
+ if (log && rename(git_path_unsafe("logs/%s", oldref),
+ git_path_unsafe(TMP_RENAMED_LOG)))
return error("unable to move logfile logs/%s to "TMP_RENAMED_LOG": %s",
oldref, strerror(errno));
@@ -1379,7 +1381,7 @@ int rename_ref(const char *oldref, const char *newref, const char *logmsg)
if (resolve_ref(newref, sha1, 1, &flag) && delete_ref(newref, sha1, REF_NODEREF)) {
if (errno==EISDIR) {
- if (remove_empty_directories(git_path("%s", newref))) {
+ if (remove_empty_directories(git_path_unsafe("%s", newref))) {
error("Directory not empty: %s", newref);
goto rollback;
}
@@ -1389,20 +1391,21 @@ int rename_ref(const char *oldref, const char *newref, const char *logmsg)
}
}
- if (log && safe_create_leading_directories(git_path("logs/%s", newref))) {
+ if (log && safe_create_leading_directories(git_path_unsafe("logs/%s", newref))) {
error("unable to create directory for %s", newref);
goto rollback;
}
retry:
- if (log && rename(git_path(TMP_RENAMED_LOG), git_path("logs/%s", newref))) {
+ if (log && rename(git_path_unsafe(TMP_RENAMED_LOG),
+ git_path_unsafe("logs/%s", newref))) {
if (errno==EISDIR || errno==ENOTDIR) {
/*
* rename(a, b) when b is an existing
* directory ought to result in ISDIR, but
* Solaris 5.8 gives ENOTDIR. Sheesh.
*/
- if (remove_empty_directories(git_path("logs/%s", newref))) {
+ if (remove_empty_directories(git_path_unsafe("logs/%s", newref))) {
error("Directory not empty: logs/%s", newref);
goto rollback;
}
@@ -1444,11 +1447,13 @@ int rename_ref(const char *oldref, const char *newref, const char *logmsg)
log_all_ref_updates = flag;
rollbacklog:
- if (logmoved && rename(git_path("logs/%s", newref), git_path("logs/%s", oldref)))
+ if (logmoved && rename(git_path_unsafe("logs/%s", newref),
+ git_path_unsafe("logs/%s", oldref)))
error("unable to restore logfile %s from %s: %s",
oldref, newref, strerror(errno));
if (!logmoved && log &&
- rename(git_path(TMP_RENAMED_LOG), git_path("logs/%s", oldref)))
+ rename(git_path_unsafe(TMP_RENAMED_LOG),
+ git_path_unsafe("logs/%s", oldref)))
error("unable to restore logfile %s from "TMP_RENAMED_LOG": %s",
oldref, strerror(errno));
@@ -1741,7 +1746,7 @@ int read_ref_at(const char *ref, unsigned long at_time, int cnt, unsigned char *
void *log_mapped;
size_t mapsz;
- logfile = git_path("logs/%s", ref);
+ logfile = git_path_unsafe("logs/%s", ref);
logfd = open(logfile, O_RDONLY, 0);
if (logfd < 0)
die_errno("Unable to read log '%s'", logfile);
@@ -1841,7 +1846,7 @@ int for_each_recent_reflog_ent(const char *ref, each_reflog_ent_fn fn, long ofs,
struct strbuf sb = STRBUF_INIT;
int ret = 0;
- logfile = git_path("logs/%s", ref);
+ logfile = git_path_unsafe("logs/%s", ref);
logfp = fopen(logfile, "r");
if (!logfp)
return -1;
@@ -1899,7 +1904,7 @@ int for_each_reflog_ent(const char *ref, each_reflog_ent_fn fn, void *cb_data)
static int do_for_each_reflog(const char *base, each_ref_fn fn, void *cb_data)
{
- DIR *dir = opendir(git_path("logs/%s", base));
+ DIR *dir = opendir(git_path_unsafe("logs/%s", base));
int retval = 0;
if (dir) {
@@ -1923,7 +1928,7 @@ static int do_for_each_reflog(const char *base, each_ref_fn fn, void *cb_data)
if (has_extension(de->d_name, ".lock"))
continue;
memcpy(log + baselen, de->d_name, namelen+1);
- if (stat(git_path("logs/%s", log), &st) < 0)
+ if (stat(git_path_unsafe("logs/%s", log), &st) < 0)
continue;
if (S_ISDIR(st.st_mode)) {
retval = do_for_each_reflog(log, fn, cb_data);
diff --git a/remote.c b/remote.c
index e2ef9911..bb85b326 100644
--- a/remote.c
+++ b/remote.c
@@ -224,7 +224,7 @@ static void add_instead_of(struct rewrite *rewrite, const char *instead_of)
static void read_remotes_file(struct remote *remote)
{
- FILE *f = fopen(git_path("remotes/%s", remote->name), "r");
+ FILE *f = fopen(git_path_unsafe("remotes/%s", remote->name), "r");
if (!f)
return;
@@ -275,7 +275,7 @@ static void read_branches_file(struct remote *remote)
char *frag;
struct strbuf branch = STRBUF_INIT;
int n = slash ? slash - remote->name : 1000;
- FILE *f = fopen(git_path("branches/%.*s", n, remote->name), "r");
+ FILE *f = fopen(git_path_unsafe("branches/%.*s", n, remote->name), "r");
char *s, *p;
int len;
diff --git a/rerere.c b/rerere.c
index dcb525a4..61f60701 100644
--- a/rerere.c
+++ b/rerere.c
@@ -22,7 +22,7 @@ static char *merge_rr_path;
const char *rerere_path(const char *hex, const char *file)
{
- return git_path("rr-cache/%s/%s", hex, file);
+ return git_path_unsafe("rr-cache/%s/%s", hex, file);
}
int has_rerere_resolution(const char *hex)
@@ -524,7 +524,7 @@ static int do_plain_rerere(struct string_list *rr, int fd)
continue;
hex = xstrdup(sha1_to_hex(sha1));
string_list_insert(rr, path)->util = hex;
- if (mkdir(git_path("rr-cache/%s", hex), 0755))
+ if (mkdir(git_path_unsafe("rr-cache/%s", hex), 0755))
continue;
handle_file(path, NULL, rerere_path(hex, "preimage"));
fprintf(stderr, "Recorded preimage for '%s'\n", path);
@@ -591,7 +591,7 @@ static int is_rerere_enabled(void)
if (!rerere_enabled)
return 0;
- rr_cache = git_path("rr-cache");
+ rr_cache = git_path_unsafe("rr-cache");
rr_cache_exists = is_directory(rr_cache);
if (rerere_enabled < 0)
return rr_cache_exists;
@@ -695,7 +695,7 @@ static void unlink_rr_item(const char *name)
unlink(rerere_path(name, "thisimage"));
unlink(rerere_path(name, "preimage"));
unlink(rerere_path(name, "postimage"));
- rmdir(git_path("rr-cache/%s", name));
+ rmdir(git_path_unsafe("rr-cache/%s", name));
}
struct rerere_gc_config_cb {
@@ -726,7 +726,7 @@ void rerere_gc(struct string_list *rr)
struct rerere_gc_config_cb cf = { 15, 60 };
git_config(git_rerere_gc_config, &cf);
- dir = opendir(git_path("rr-cache"));
+ dir = opendir(git_path_unsafe("rr-cache"));
if (!dir)
die_errno("unable to open rr-cache directory");
while ((e = readdir(dir))) {
@@ -760,5 +760,5 @@ void rerere_clear(struct string_list *merge_rr)
if (!has_rerere_resolution(name))
unlink_rr_item(name);
}
- unlink_or_warn(git_path("MERGE_RR"));
+ unlink_or_warn(git_path_unsafe("MERGE_RR"));
}
diff --git a/run-command.c b/run-command.c
index 1c510438..598e41dd 100644
--- a/run-command.c
+++ b/run-command.c
@@ -612,11 +612,11 @@ int run_hook(const char *index_file, const char *name, ...)
va_list args;
int ret;
- if (access(git_path("hooks/%s", name), X_OK) < 0)
+ if (access(git_path_unsafe("hooks/%s", name), X_OK) < 0)
return 0;
va_start(args, name);
- argv_array_push(&argv, git_path("hooks/%s", name));
+ argv_array_push(&argv, git_path_unsafe("hooks/%s", name));
while ((p = va_arg(args, const char *)))
argv_array_push(&argv, p);
va_end(args);
diff --git a/sequencer.c b/sequencer.c
index bc2c046a..2e29152c 100644
--- a/sequencer.c
+++ b/sequencer.c
@@ -8,10 +8,10 @@ void remove_sequencer_state(int aggressive)
struct strbuf seq_dir = STRBUF_INIT;
struct strbuf seq_old_dir = STRBUF_INIT;
- strbuf_addf(&seq_dir, "%s", git_path(SEQ_DIR));
- strbuf_addf(&seq_old_dir, "%s", git_path(SEQ_OLD_DIR));
+ strbuf_addf(&seq_dir, "%s", git_path_unsafe(SEQ_DIR));
+ strbuf_addf(&seq_old_dir, "%s", git_path_unsafe(SEQ_OLD_DIR));
remove_dir_recursively(&seq_old_dir, 0);
- rename(git_path(SEQ_DIR), git_path(SEQ_OLD_DIR));
+ rename(git_path_unsafe(SEQ_DIR), git_path_unsafe(SEQ_OLD_DIR));
if (aggressive)
remove_dir_recursively(&seq_old_dir, 0);
strbuf_release(&seq_dir);
diff --git a/server-info.c b/server-info.c
index 9ec744e9..348a3447 100644
--- a/server-info.c
+++ b/server-info.c
@@ -243,7 +243,7 @@ int update_server_info(int force)
errs = errs | update_info_packs(force);
/* remove leftover rev-cache file if there is any */
- unlink_or_warn(git_path("info/rev-cache"));
+ unlink_or_warn(git_path_unsafe("info/rev-cache"));
return errs;
}
diff --git a/sha1_file.c b/sha1_file.c
index 86705bc9..ba7eca89 100644
--- a/sha1_file.c
+++ b/sha1_file.c
@@ -382,7 +382,7 @@ static void read_info_alternates(const char * relative_base, int depth)
void add_to_alternates_file(const char *reference)
{
struct lock_file *lock = xcalloc(1, sizeof(struct lock_file));
- int fd = hold_lock_file_for_append(lock, git_path("objects/info/alternates"), LOCK_DIE_ON_ERROR);
+ int fd = hold_lock_file_for_append(lock, git_path_unsafe("objects/info/alternates"), LOCK_DIE_ON_ERROR);
char *alt = mkpath("%s\n", reference);
write_or_die(fd, alt, strlen(alt));
if (commit_lock_file(lock))
@@ -2706,7 +2706,7 @@ static int index_stream(unsigned char *sha1, int fd, size_t size,
int len, tmpfd;
strbuf_addstr(&export_marks, "--export-marks=");
- strbuf_addstr(&export_marks, git_path("hashstream_XXXXXX"));
+ strbuf_addstr(&export_marks, git_path_unsafe("hashstream_XXXXXX"));
tmpfile = export_marks.buf + strlen("--export-marks=");
tmpfd = git_mkstemp_mode(tmpfile, 0600);
if (tmpfd < 0)
diff --git a/shallow.c b/shallow.c
index a0363dea..d721397a 100644
--- a/shallow.c
+++ b/shallow.c
@@ -25,7 +25,7 @@ int is_repository_shallow(void)
if (is_shallow >= 0)
return is_shallow;
- fp = fopen(git_path("shallow"), "r");
+ fp = fopen(git_path_unsafe("shallow"), "r");
if (!fp) {
is_shallow = 0;
return is_shallow;
diff --git a/transport.c b/transport.c
index 51814b5d..cc0ca04c 100644
--- a/transport.c
+++ b/transport.c
@@ -203,7 +203,7 @@ static struct ref *get_refs_via_rsync(struct transport *transport, int for_push)
/* copy the refs to the temporary directory */
- strbuf_addstr(&temp_dir, git_path("rsync-refs-XXXXXX"));
+ strbuf_addstr(&temp_dir, git_path_unsafe("rsync-refs-XXXXXX"));
if (!mkdtemp(temp_dir.buf))
die_errno ("Could not make temporary directory");
temp_dir_len = temp_dir.len;
@@ -366,7 +366,7 @@ static int rsync_transport_push(struct transport *transport,
/* copy the refs to the temporary directory; they could be packed. */
- strbuf_addstr(&temp_dir, git_path("rsync-refs-XXXXXX"));
+ strbuf_addstr(&temp_dir, git_path_unsafe("rsync-refs-XXXXXX"));
if (!mkdtemp(temp_dir.buf))
die_errno ("Could not make temporary directory");
strbuf_addch(&temp_dir, '/');
diff --git a/unpack-trees.c b/unpack-trees.c
index 8282f5e5..44f408b8 100644
--- a/unpack-trees.c
+++ b/unpack-trees.c
@@ -1010,7 +1010,7 @@ int unpack_trees(unsigned len, struct tree_desc *t, struct unpack_trees_options
if (!core_apply_sparse_checkout || !o->update)
o->skip_sparse_checkout = 1;
if (!o->skip_sparse_checkout) {
- if (add_excludes_from_file_to_list(git_path("info/sparse-checkout"), "", 0, NULL, &el, 0) < 0)
+ if (add_excludes_from_file_to_list(git_path_unsafe("info/sparse-checkout"), "", 0, NULL, &el, 0) < 0)
o->skip_sparse_checkout = 1;
else
o->el = ⪙
--
1.7.8.rc0
^ permalink raw reply related
* [PATCH 2/3] Bigfile: dynamically allocate buffer for marks file name
From: Jonathan Nieder @ 2011-11-16 8:04 UTC (permalink / raw)
To: Ramkumar Ramachandra
Cc: Junio C Hamano, Git List, Nguyễn Thái Ngọc Duy
In-Reply-To: <20111116075955.GB13706@elie.hsd1.il.comcast.net>
This prevents a buffer overrun that could otherwise be triggered by
creating a .git file with a long destination path and trying to "git
add" a file larger than the big-file threshold (which defaults to 512
MiB), ever since v1.7.6-rc0~31^2 (Bigfile: teach "git add" to send a
large file straight to a pack, 2011-05-08).
Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
---
sha1_file.c | 20 +++++++++++++++-----
1 files changed, 15 insertions(+), 5 deletions(-)
diff --git a/sha1_file.c b/sha1_file.c
index 27f3b9b2..86705bc9 100644
--- a/sha1_file.c
+++ b/sha1_file.c
@@ -2697,20 +2697,28 @@ static int index_stream(unsigned char *sha1, int fd, size_t size,
unsigned flags)
{
struct child_process fast_import;
- char export_marks[512];
- const char *argv[] = { "fast-import", "--quiet", export_marks, NULL };
- char tmpfile[512];
+ const char *argv[4]; /* command, two args, NULL */
+ const char **arg;
+ struct strbuf export_marks = STRBUF_INIT;
+ char *tmpfile;
char fast_import_cmd[512];
char buf[512];
int len, tmpfd;
- strcpy(tmpfile, git_path("hashstream_XXXXXX"));
+ strbuf_addstr(&export_marks, "--export-marks=");
+ strbuf_addstr(&export_marks, git_path("hashstream_XXXXXX"));
+ tmpfile = export_marks.buf + strlen("--export-marks=");
tmpfd = git_mkstemp_mode(tmpfile, 0600);
if (tmpfd < 0)
die_errno("cannot create tempfile: %s", tmpfile);
if (close(tmpfd))
die_errno("cannot close tempfile: %s", tmpfile);
- sprintf(export_marks, "--export-marks=%s", tmpfile);
+
+ arg = argv;
+ *arg++ = "fast-import";
+ *arg++ = "--quiet";
+ *arg++ = export_marks.buf;
+ *arg++ = NULL;
memset(&fast_import, 0, sizeof(fast_import));
fast_import.in = -1;
@@ -2754,6 +2762,8 @@ static int index_stream(unsigned char *sha1, int fd, size_t size,
memcmp(":1 ", buf, 3) ||
get_sha1_hex(buf + 3, sha1))
die_errno("index-stream: unexpected fast-import mark: <%s>", buf);
+
+ strbuf_release(&export_marks);
return 0;
}
--
1.7.8.rc0
^ permalink raw reply related
* [PATCH 1/3] do not let git_path clobber errno when reporting errors
From: Jonathan Nieder @ 2011-11-16 8:03 UTC (permalink / raw)
To: Ramkumar Ramachandra
Cc: Junio C Hamano, Git List, Nguyễn Thái Ngọc Duy
In-Reply-To: <20111116075955.GB13706@elie.hsd1.il.comcast.net>
Because git_path() calls vsnprintf(), code like
fd = open(git_path("SQUASH_MSG"), O_WRONLY | O_CREAT, 0666);
die_errno(_("Could not write to '%s'"), git_path("SQUASH_MSG"));
can end up printing an error indicator from vsnprintf() instead of
open() by mistake. Store the path we are trying to write to in a
temporary variable and pass _that_ to die_errno(), so the messages
written by git cherry-pick/revert and git merge can avoid this source
of confusion.
Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
---
builtin/merge.c | 49 +++++++++++++++++++++++++++++--------------------
builtin/revert.c | 9 +++++----
2 files changed, 34 insertions(+), 24 deletions(-)
diff --git a/builtin/merge.c b/builtin/merge.c
index dffd5ec1..2870a6af 100644
--- a/builtin/merge.c
+++ b/builtin/merge.c
@@ -316,13 +316,15 @@ static void squash_message(struct commit *commit)
struct rev_info rev;
struct strbuf out = STRBUF_INIT;
struct commit_list *j;
+ const char *filename;
int fd;
struct pretty_print_context ctx = {0};
printf(_("Squash commit -- not updating HEAD\n"));
- fd = open(git_path("SQUASH_MSG"), O_WRONLY | O_CREAT, 0666);
+ filename = git_path("SQUASH_MSG");
+ fd = open(filename, O_WRONLY | O_CREAT, 0666);
if (fd < 0)
- die_errno(_("Could not write to '%s'"), git_path("SQUASH_MSG"));
+ die_errno(_("Could not write to '%s'"), filename);
init_revisions(&rev, NULL);
rev.ignore_merges = 1;
@@ -492,14 +494,16 @@ static void merge_name(const char *remote, struct strbuf *msg)
if (!strcmp(remote, "FETCH_HEAD") &&
!access(git_path("FETCH_HEAD"), R_OK)) {
+ const char *filename;
FILE *fp;
struct strbuf line = STRBUF_INIT;
char *ptr;
- fp = fopen(git_path("FETCH_HEAD"), "r");
+ filename = git_path("FETCH_HEAD");
+ fp = fopen(filename, "r");
if (!fp)
die_errno(_("could not open '%s' for reading"),
- git_path("FETCH_HEAD"));
+ filename);
strbuf_getline(&line, fp, '\n');
fclose(fp);
ptr = strstr(line.buf, "\tnot-for-merge\t");
@@ -847,20 +851,22 @@ static void add_strategies(const char *string, unsigned attr)
static void write_merge_msg(struct strbuf *msg)
{
- int fd = open(git_path("MERGE_MSG"), O_WRONLY | O_CREAT, 0666);
+ const char *filename = git_path("MERGE_MSG");
+ int fd = open(filename, O_WRONLY | O_CREAT, 0666);
if (fd < 0)
die_errno(_("Could not open '%s' for writing"),
- git_path("MERGE_MSG"));
+ filename);
if (write_in_full(fd, msg->buf, msg->len) != msg->len)
- die_errno(_("Could not write to '%s'"), git_path("MERGE_MSG"));
+ die_errno(_("Could not write to '%s'"), filename);
close(fd);
}
static void read_merge_msg(struct strbuf *msg)
{
+ const char *filename = git_path("MERGE_MSG");
strbuf_reset(msg);
- if (strbuf_read_file(msg, git_path("MERGE_MSG"), 0) < 0)
- die_errno(_("Could not read from '%s'"), git_path("MERGE_MSG"));
+ if (strbuf_read_file(msg, filename, 0) < 0)
+ die_errno(_("Could not read from '%s'"), filename);
}
static void write_merge_state(void);
@@ -948,13 +954,14 @@ static int finish_automerge(struct commit *head,
static int suggest_conflicts(int renormalizing)
{
+ const char *filename;
FILE *fp;
int pos;
- fp = fopen(git_path("MERGE_MSG"), "a");
+ filename = git_path("MERGE_MSG");
+ fp = fopen(filename, "a");
if (!fp)
- die_errno(_("Could not open '%s' for writing"),
- git_path("MERGE_MSG"));
+ die_errno(_("Could not open '%s' for writing"), filename);
fprintf(fp, "\nConflicts:\n");
for (pos = 0; pos < active_nr; pos++) {
struct cache_entry *ce = active_cache[pos];
@@ -1046,6 +1053,7 @@ static int setup_with_upstream(const char ***argv)
static void write_merge_state(void)
{
+ const char *filename;
int fd;
struct commit_list *j;
struct strbuf buf = STRBUF_INIT;
@@ -1053,24 +1061,25 @@ static void write_merge_state(void)
for (j = remoteheads; j; j = j->next)
strbuf_addf(&buf, "%s\n",
sha1_to_hex(j->item->object.sha1));
- fd = open(git_path("MERGE_HEAD"), O_WRONLY | O_CREAT, 0666);
+ filename = git_path("MERGE_HEAD");
+ fd = open(filename, O_WRONLY | O_CREAT, 0666);
if (fd < 0)
- die_errno(_("Could not open '%s' for writing"),
- git_path("MERGE_HEAD"));
+ die_errno(_("Could not open '%s' for writing"), filename);
if (write_in_full(fd, buf.buf, buf.len) != buf.len)
- die_errno(_("Could not write to '%s'"), git_path("MERGE_HEAD"));
+ die_errno(_("Could not write to '%s'"), filename);
close(fd);
strbuf_addch(&merge_msg, '\n');
write_merge_msg(&merge_msg);
- fd = open(git_path("MERGE_MODE"), O_WRONLY | O_CREAT | O_TRUNC, 0666);
+
+ filename = git_path("MERGE_MODE");
+ fd = open(filename, O_WRONLY | O_CREAT | O_TRUNC, 0666);
if (fd < 0)
- die_errno(_("Could not open '%s' for writing"),
- git_path("MERGE_MODE"));
+ die_errno(_("Could not open '%s' for writing"), filename);
strbuf_reset(&buf);
if (!allow_fast_forward)
strbuf_addf(&buf, "no-ff");
if (write_in_full(fd, buf.buf, buf.len) != buf.len)
- die_errno(_("Could not write to '%s'"), git_path("MERGE_MODE"));
+ die_errno(_("Could not write to '%s'"), filename);
close(fd);
}
diff --git a/builtin/revert.c b/builtin/revert.c
index 87df70ed..985f95b0 100644
--- a/builtin/revert.c
+++ b/builtin/revert.c
@@ -288,17 +288,18 @@ static char *get_encoding(const char *message)
static void write_cherry_pick_head(struct commit *commit)
{
+ const char *filename;
int fd;
struct strbuf buf = STRBUF_INIT;
strbuf_addf(&buf, "%s\n", sha1_to_hex(commit->object.sha1));
- fd = open(git_path("CHERRY_PICK_HEAD"), O_WRONLY | O_CREAT, 0666);
+ filename = git_path("CHERRY_PICK_HEAD");
+ fd = open(filename, O_WRONLY | O_CREAT, 0666);
if (fd < 0)
- die_errno(_("Could not open '%s' for writing"),
- git_path("CHERRY_PICK_HEAD"));
+ die_errno(_("Could not open '%s' for writing"), filename);
if (write_in_full(fd, buf.buf, buf.len) != buf.len || close(fd))
- die_errno(_("Could not write to '%s'"), git_path("CHERRY_PICK_HEAD"));
+ die_errno(_("Could not write to '%s'"), filename);
strbuf_release(&buf);
}
--
1.7.8.rc0
^ permalink raw reply related
* [PATCH 0/3] avoiding unintended consequences of git_path() usage
From: Jonathan Nieder @ 2011-11-16 7:59 UTC (permalink / raw)
To: Ramkumar Ramachandra
Cc: Junio C Hamano, Git List, Nguyễn Thái Ngọc Duy
In-Reply-To: <CALkWK0kOrGzjcGNcf2qPahJSgkvCsQwSrEfAA3wj6PqnMzDBVQ@mail.gmail.com>
Ramkumar Ramachandra wrote:
> Junio C Hamano wrote:
>> Or perhaps http://thread.gmane.org/gmane.comp.version-control.git/184963/focus=185436
>
> I noticed that sha1_to_hex() also operates like this. The
> resolve_ref() function is really important, but using the same
> technique for these tiny functions is probably an overkill
I don't follow. Do you mean that not being confusing is overkill,
because the function is small that no one will bother to look up the
right semantics? Wait, that sentence didn't come out the way I
wanted. ;-)
Jokes aside, here's a rough series to do the git_path ->
git_path_unsafe renaming. While writing it, I noticed a couple of
bugs, hence the two patches before the last one. Patch 2 is the more
interesting one.
Patches are against "master", but patch 2 probably should be thought
of as being against maint-1.7.6. Improvements welcome, as always.
Thanks,
Jonathan Nieder (3):
do not let git_path clobber errno when reporting errors
Bigfile: dynamically allocate buffer for marks file name
rename git_path() to git_path_unsafe()
Documentation/technical/api-string-list.txt | 5 +-
attr.c | 2 +-
bisect.c | 8 ++--
branch.c | 12 ++--
builtin/add.c | 2 +-
builtin/commit.c | 57 ++++++++++++-----------
builtin/config.c | 4 +-
builtin/fetch-pack.c | 4 +-
builtin/fetch.c | 5 +-
builtin/fsck.c | 2 +-
builtin/init-db.c | 12 ++--
builtin/merge.c | 67 +++++++++++++++------------
builtin/notes.c | 2 +-
builtin/remote.c | 6 +-
builtin/reset.c | 2 +-
builtin/revert.c | 25 +++++-----
cache.h | 3 +-
contrib/examples/builtin-fetch--tool.c | 4 +-
dir.c | 2 +-
fast-import.c | 2 +-
http-backend.c | 2 +-
notes-merge.c | 22 +++++----
pack-refs.c | 6 +-
path.c | 2 +-
refs.c | 51 +++++++++++---------
remote.c | 4 +-
rerere.c | 12 ++--
run-command.c | 4 +-
sequencer.c | 6 +-
server-info.c | 2 +-
sha1_file.c | 22 ++++++--
shallow.c | 2 +-
transport.c | 4 +-
unpack-trees.c | 2 +-
34 files changed, 200 insertions(+), 167 deletions(-)
--
1.7.8.rc0
^ permalink raw reply
* Re: [PATCH 3/4] ll-merge: initialize default_opts const
From: Junio C Hamano @ 2011-11-16 7:49 UTC (permalink / raw)
To: Ramkumar Ramachandra; +Cc: Junio C Hamano, Git List, Thomas Rast
In-Reply-To: <CALkWK0mVxxq0345B_OJQwejpTBD=evOU_iAv39CvXv4mAi=09A@mail.gmail.com>
Ramkumar Ramachandra <artagnon@gmail.com> writes:
> Hi Junio,
>
> Junio C Hamano wrote:
>> Ramkumar Ramachandra <artagnon@gmail.com> writes:
>>> [...]
>>> - static const struct ll_merge_options default_opts;
>>> + static const struct ll_merge_options default_opts = {0, 0, 0, 0};
>>
>> Doesn't "static" tell us that it will be in BSS, initialized to all zero
>> by definition?
>
> I'm uncertain about whether the C89 standard says this explicitly- icc
> is more pedantic than most mainstream compilers.
Actually I take a part of the comment back; as this is "static const", it
is entirely plausible for a compiler to tell the linker to put it in rodata
instead of bss, to cause any attempt to modify it to segv.
A datum that is implicitly initialized to all zero and not allowed to be
modified might appear suspect to some compiler writers (especially when
they are under influence ;-)), so I am not so surprised if a compiler
issued a warning saying "did you forget to initialize it?".
^ permalink raw reply
* Re: [PATCH 3/5] sequencer: sequencer state is useless without todo
From: Junio C Hamano @ 2011-11-16 7:38 UTC (permalink / raw)
To: Ramkumar Ramachandra; +Cc: Jonathan Nieder, Git List
In-Reply-To: <CALkWK0kOrGzjcGNcf2qPahJSgkvCsQwSrEfAA3wj6PqnMzDBVQ@mail.gmail.com>
Ramkumar Ramachandra <artagnon@gmail.com> writes:
> I noticed that sha1_to_hex() also operates like this.
A function to externalize our internal representation like sha1_to_hex()
is not such a big problem in practice, as the lifetime of its result is
inherently much shorter.
Anybody sane with a datum that eventually needs to be externalized will
keep it in its internal representation as long as possible, and then call
such an internal-to-external function just before it becomes absolutely
necessary to externalize it (e.g. calling printf(), packet_write(), etc).
This is because the whole point of having an internal representation
(e.g. when our code talks about an object name, we always use "unsigned
char[20]") is so that all of our functions can use that representation to
pass it around. It would be insane to call such a function earlier than
necessary, having to pass external representation around.
On the other hand, resolve_ref() is an interface to canonicalize external
representation into a form suitable to be kept and passed around as its
internal representation. The lifetime of its result fundamentally has to
be a lot longer than that of functions that work in the opposite
direction, e.g. sha1_to_hex().
^ permalink raw reply
* Re: Git 1.7.5 problem with HTTPS
From: Tay Ray Chuan @ 2011-11-16 7:34 UTC (permalink / raw)
To: Dmitry Smirnov; +Cc: Junio C Hamano, Shawn Pearce, git
In-Reply-To: <CACf55T6SRAfdOP1+qQdjeFv13B=G8w+DR-GCSEz=6swFhLJzcw@mail.gmail.com>
On Wed, Nov 16, 2011 at 3:11 PM, Dmitry Smirnov <divis1969@gmail.com> wrote:
> What if problem is caused by curl or TLS lib (libcurl-gnutls?) which
> is used by my git? Is there any to log something from git-remote-https
> ?
You can run git with GIT_CURL_VERBOSE set, like this
GIT_CURL_VERBOSE=1 git ls-remote ...
--
Cheers,
Ray Chuan
^ permalink raw reply
* Re: Git, Parrot, Perl6, Rakudo for G4 MAC
From: Jakub Narebski @ 2011-11-16 7:21 UTC (permalink / raw)
To: greggallen; +Cc: Sitaram Chamarty, Hilco Wijbenga, git
In-Reply-To: <CAKjR-Ruj0TEST5OdB4HGh_2Ox2xL9k7bqqnJvx8O0O5T0SziDA@mail.gmail.com>
greggallen@gmail.com wrote:
> Thank you very much for all your help. After a tiny bit of
> consideration, I've decided to sell my G4, for whatever I can get on
> the local Craigslist, and install Linux, or FreeBSD on this &^%^$$&*!!
> Wintel machine.
>
> Copying my several dozen useful Perl and shell scripts, will be much
> easier to accomplish than "GITting" the other stuff to install on a
> PPC MAC. I love programming, but INSTALLING software is boring!
Hmmm... isn't there some pre-compiled Git to be installed on PPC Mac
(Homebrew, git-osx-installer linked from Git Homepage)?
--
Jakub Narebski
Poland
^ permalink raw reply
* Re: Git 1.7.5 problem with HTTPS
From: Junio C Hamano @ 2011-11-16 7:18 UTC (permalink / raw)
To: Dmitry Smirnov; +Cc: Shawn Pearce, git
In-Reply-To: <CACf55T6SRAfdOP1+qQdjeFv13B=G8w+DR-GCSEz=6swFhLJzcw@mail.gmail.com>
Dmitry Smirnov <divis1969@gmail.com> writes:
> 2011/11/16 Junio C Hamano <gitster@pobox.com>:
>> $ git ls-remote https://git.kernel.org/pub/scm/git/git.git |
>> grep -e HEAD -e master
>
> in my case this command produce no output.
>
> What if problem is caused by curl or TLS lib (libcurl-gnutls?) which
> is used by my git?
Yeah, this is sounding very likely that this is an issue at the SSL/TLS
layer underneath whatever Git speaks.
^ permalink raw reply
* Re: Git 1.7.5 problem with HTTPS
From: Dmitry Smirnov @ 2011-11-16 7:11 UTC (permalink / raw)
To: Junio C Hamano; +Cc: Shawn Pearce, git
In-Reply-To: <7v1ut9uglb.fsf@alter.siamese.dyndns.org>
2011/11/16 Junio C Hamano <gitster@pobox.com>:
> $ git ls-remote https://git.kernel.org/pub/scm/git/git.git |
> grep -e HEAD -e master
in my case this command produce no output.
What if problem is caused by curl or TLS lib (libcurl-gnutls?) which
is used by my git? Is there any to log something from git-remote-https
?
Dmitry
^ permalink raw reply
* Re: Git, Parrot, Perl6, Rakudo for G4 MAC
From: greggallen @ 2011-11-16 7:07 UTC (permalink / raw)
To: Sitaram Chamarty; +Cc: Jakub Narebski, Hilco Wijbenga, git
In-Reply-To: <CAMK1S_jcThEB=_w=miGBncmTEy8jz6_T-QHv7g-C5s3Hi+X6Lg@mail.gmail.com>
Thank you very much for all your help. After a tiny bit of
consideration, I've decided to sell my G4, for whatever I can get on
the local Craigslist, and install Linux, or FreeBSD on this &^%^$$&*!!
Wintel machine.
Copying my several dozen useful Perl and shell scripts, will be much
easier to accomplish than "GITting" the other stuff to install on a
PPC MAC. I love programming, but INSTALLING software is boring!
Thanks again,
Greg Allen
GreggAllen@gmail.com
On 11/15/11, Sitaram Chamarty <sitaramc@gmail.com> wrote:
> 2011/11/15 Jakub Narebski <jnareb@gmail.com>:
>
>> Git requires Perl version 5.8 at least, so you should not have any
>> problems here.
>
> One day someone [1] reminded me that git does not require perl. Some
> features, like git add -p, require it but git can be built without
> perl.
>
> [1] on irc, while discussing my stated requirements for gitolite
>
--
**********************************************
Descargo de responsabilidad:
(Nulo donde esté prohibido, su kilometraje puede variar, consulte con
su médico, todos los derechos reservados, cualquier retransmisión o
retransmisión de las descripciones y las cuentas de este juego está
prohibida sin el consentimiento expreso por escrito de la Major League
Baseball).
Disclaimer:
(Void where prohibited, your mileage may vary, check with your doctor,
all rights reserved, any rebroadcast or retransmission of the
descriptions and accounts of this game is prohibited without the
expressed written consent of Major League Baseball.)
Haftungsausschluss:
(Void, wo die Leistung kann variieren, fragen Sie Ihren Arzt verboten,
alle Rechte vorbehalten, jegliche Weiterverbreitung oder
Weiterverbreitung von Beschreibungen und Berichte über dieses Spiel
ist ohne ausdrückliche schriftliche Zustimmung der Major League
Baseball verboten.)
Rejettent la Déclaration:
(Nul si interdit, votre kilométrage peut varier, vérifiez auprès de
votre médecin, tous droits réservés, toute rediffusion ou
retransmission des descriptions et des comptes de ce jeu est interdite
sans l'accord écrit de la Major League Baseball).
Negano la Dichiarazione:
(valido dove proibito, le prestazioni possono variare, verificare con
il medico, tutti i diritti riservati, ogni ritrasmissione o
ritrasmissione delle descrizioni e dei conti di questo gioco è vietato
senza il consenso scritto della Major League Baseball.)
^ permalink raw reply
* Re: Git 1.7.5 problem with HTTPS
From: Dmitry Smirnov @ 2011-11-16 7:04 UTC (permalink / raw)
To: git; +Cc: Shawn Pearce
In-Reply-To: <CAJo=hJvdstr39suGMwxNoT+_cKThxsEYHi96eqja7HuHyPmhWA@mail.gmail.com>
2011/11/15 Shawn Pearce <spearce@spearce.org>:
> I would suggest starting over by downloading repo per [1] and using
> that script to start the process.
Cloning of the repo.git repository produces the same error
warning: remote HEAD refers to nonexistent ref, unable to checkout.
That is why I tried to use another repository...
^ permalink raw reply
* Re: [PATCH] revert: prettify fatal messages
From: Jonathan Nieder @ 2011-11-16 6:42 UTC (permalink / raw)
To: Ramkumar Ramachandra; +Cc: Junio C Hamano, Git List, Matthieu Moy
In-Reply-To: <CALkWK0m+us0rCx61+SwSsKuO7qK5mbCs0MpoAzB4ja=wBA+Xjw@mail.gmail.com>
Ramkumar Ramachandra wrote:
> To avoid confusion, reverts should always look
> like the following:
>
> Revert [commit message]
>
> This reverts commit [unabbreviated sha1 hex].
Don't forget the description of why it is being reverted. :)
Actually, I think Matthieu's confusion makes a lot of sense. I don't
think it matters very much, but it can sometimes be clearer to say
"cherry-pick/revert: remove spurious period in error message".
Another benefit to moving the juicy part to sequencer.c, I guess.
^ permalink raw reply
* Re: [PATCH 3/7] sequencer: handle single-commit pick as special case
From: Ramkumar Ramachandra @ 2011-11-16 6:30 UTC (permalink / raw)
To: Junio C Hamano; +Cc: Git List, Jonathan Nieder
In-Reply-To: <7v62ilujya.fsf@alter.siamese.dyndns.org>
Hi Junio,
Junio C Hamano wrote:
> Ramkumar Ramachandra <artagnon@gmail.com> writes:
>> [...]
> But we are already in agreement on this point, I think. Didn't I say:
Yes, yes. I was just thinking out loud so it'll help me write a new
commit message. Sorry for the noise.
>> 2. In the case of multi-commit picking, there's an additional layer of
>> decision making: did the conflict occur in the last commit in the
>> range?
>
> Again, it would be the same thing. If the implementation forces that
> decision, that would be a bug, no?
>
> My understanding is that multi-commit form of cherry-pick and revert
> intended to allow two forms of "user done helping and telling the command
> to continue" at any stage, be it the first, in the middle, or the last
> operation in a series:
>
> - User resolves, adds and commits, and then tells the command to
> continue. The command notices that the user has committed, and goes on
> to the next task; or
>
> - User resolves, adds, and then tells the command to continue. The
> command notices that the user has not committed, makes a commit and
> goes on to the next task.
Yep, this is exactly how it'll work after the series :D
Thanks.
-- Ram
^ permalink raw reply
* Re: [PATCH] revert: prettify fatal messages
From: Ramkumar Ramachandra @ 2011-11-16 6:23 UTC (permalink / raw)
To: Junio C Hamano; +Cc: Git List, Jonathan Nieder, Matthieu Moy
In-Reply-To: <7vvcqkswpu.fsf@alter.siamese.dyndns.org>
Hi,
Matthieu Moy wrote:
> (I just misread the subject line at first, and understood that this was> a revert of an earlier commit, while this is actually a commit touching> the "revert" part of Git)
Reminds me of an earlier note Jonathan made about the git-revert
commit message format. To avoid confusion, reverts should always look
like the following:
Revert [commit message]
This reverts commit [unabbreviated sha1 hex].
Junio C Hamano wrote:
> Ramkumar Ramachandra <artagnon@gmail.com> writes:
>> Candidate for 'maint'?
>
> Too minor to matter when 'master' is already at -rc2.
Ah, I haven't been paying much attention to these release cycles. I
suppose we can put this patch in `master` after the release? I wince
everytime I see these ugly fatal messages: it happens shockingly often
while testing :)
Thanks.
-- Ram
^ permalink raw reply
* Re: [PATCH 3/5] sequencer: sequencer state is useless without todo
From: Ramkumar Ramachandra @ 2011-11-16 6:17 UTC (permalink / raw)
To: Junio C Hamano; +Cc: Jonathan Nieder, Git List
In-Reply-To: <7v7h31wduv.fsf@alter.siamese.dyndns.org>
Hi,
Jonathan Nieder wrote:
> Just use a sane idiom. Which means: as few git_path() values in
> flight at a time as possible.
Makes sense, thanks.
Junio C Hamano wrote:
> Or perhaps http://thread.gmane.org/gmane.comp.version-control.git/184963/focus=185436
I noticed that sha1_to_hex() also operates like this. The
resolve_ref() function is really important, but using the same
technique for these tiny functions is probably an overkill; something
in `Documentation/technical` perhaps?
Thanks.
-- Ram
^ permalink raw reply
* Re: [PATCH 3/4] ll-merge: initialize default_opts const
From: Ramkumar Ramachandra @ 2011-11-16 6:06 UTC (permalink / raw)
To: Junio C Hamano; +Cc: Git List, Thomas Rast
In-Reply-To: <7vty65t1qp.fsf@alter.siamese.dyndns.org>
Hi Junio,
Junio C Hamano wrote:
> Ramkumar Ramachandra <artagnon@gmail.com> writes:
>> [...]
>> diff --git a/ll-merge.c b/ll-merge.c
>> index da59738..205aed3 100644
>> --- a/ll-merge.c
>> +++ b/ll-merge.c
>> @@ -351,7 +351,7 @@ int ll_merge(mmbuffer_t *result_buf,
>> const struct ll_merge_options *opts)
>> {
>> static struct git_attr_check check[2];
>> - static const struct ll_merge_options default_opts;
>> + static const struct ll_merge_options default_opts = {0, 0, 0, 0};
>
> Doesn't "static" tell us that it will be in BSS, initialized to all zero
> by definition?
I'm uncertain about whether the C89 standard says this explicitly- icc
is more pedantic than most mainstream compilers. Feel free to drop
this part if you don't think it adds value.
Thanks.
-- Ram
^ permalink raw reply
* Re: [PATCH] git-show-ref: fix escaping in asciidoc source
From: Michael Haggerty @ 2011-11-16 5:52 UTC (permalink / raw)
To: Junio C Hamano; +Cc: git
In-Reply-To: <7vk471urfy.fsf@alter.siamese.dyndns.org>
On 11/15/2011 08:16 PM, Junio C Hamano wrote:
> Michael Haggerty <mhagger@alum.mit.edu> writes:
>> Did this one fall through the cracks? I don't see it in your tree.
>
> Yeah, I was wondering if we can have a concise description in what context
> any "^" must be spelled as {caret} and what other context "^" can be
> spelled literally, and possibly which versions of AsciiDoc toolchain have
> this issue [*1*]. Without a clear guideline, people may unknowingly use
> literal "^" to new paragraphs, or perhaps worse yet, spell {caret} that
> end up being shown literally.
>
> Since I didn't find a clear pattern other than that "^" can and should be
> literally given in a literal paragraph (i.e. an indented paragraph or
> inside a listing/literal block that shows program examples), I was meaning
> to ask you if you knew the rules better than I did, and I stopped there,
> forgetting to follow through.
I didn't know anything about asciidoc, and just tried to fix it using a
bit of cargo-cult programming.
Now I just did about an hour of research about asciidoc (but I still
don't feel very enlightened). It seems that asciidoc was interpreting
the caret, paired with one earlier in the paragraph, as markup asking
for the enclosed text to be superscripted [1]. Apparently, single
carets in a paragraph are not treated as markup, which would explain
some apparent inconsistency about when carets need to be quoted. But it
would seem prudent to escape all carets that don't appear in literal blocks.
Constructs like "{caret}" are "simple attribute references". In this
particular case, the attribute that it is referencing is not built into
asciidoc but rather defined in the file Documentation/asciidoc.conf.
Empirically it seems that curly braces need to be escaped if they can be
interpreted to be part of an attribute reference, but not otherwise.
For example, curly braces with nothing inside of them like "{}" don't
necessarily need to be quoted, but it doesn't hurt if they are quoted to
"\{\}".
The backslash escape rules are a bit mysterious to me. Backslash can be
used to escape some special characters. For example, they can be used
to escape leading special quoting characters to avoid the special
effect, like "\_not italic_" [3]. They can also be used to suppress
attribute references, like "\{caret}" [4]. But it doesn't appear
possible to use a backslash to escape another backslash; for example
"\\{carat}" is rendered as "\{carat}". In such cases, the backslash can
be spelled "{backslash}" (which is also defined in asciidoc.conf).
How to quote a monstrosity like the regexp in git-show-ref.txt? We want
it to render as
^(?:<anything>\s)?<refname>(?:\^{})?$
, probably in monospaced font and surrounded by double quotes. asciidoc
supports a bewildering variety of quoting mechanisms [5]. Empirically,
"`^(?:<anything>\s)?<refname>(?:\^{})?$`"
doesn't work (the backticks don't suppress superscripting).
A pedestrian option is
"`{caret}(?:<anything>\s)?<refname>(?:{backslash}{caret}\{\})?$`"
or
"`{caret}(?:<anything>\s)?<refname>(?:{backslash}{caret}{})?$`"
Or the whole blob can be quoted en masse using $$:
"`$$^(?:<anything>\s)?<refname>(?:\^{})?$$$`"
I don't know whether it treats the last dollar signs as "$$ $" or "$
$$", but either way the result looks OK.
I can't believe I spent my whole morning on this :-(
Michael
[1]
http://www.methods.co.nz/asciidoc/userguide.html#_superscripts_and_subscripts
[2]
http://www.methods.co.nz/asciidoc/userguide.html#_simple_attributes_references
[3] http://www.methods.co.nz/asciidoc/userguide.html#X51
[4] http://www.methods.co.nz/asciidoc/userguide.html#_attribute_references
[5] http://www.methods.co.nz/asciidoc/userguide.html#X77
--
Michael Haggerty
mhagger@alum.mit.edu
http://softwareswirl.blogspot.com/
^ permalink raw reply
* Re: odd name-rev behavior?
From: Junio C Hamano @ 2011-11-16 5:41 UTC (permalink / raw)
To: Tim Walberg; +Cc: git
In-Reply-To: <20111116014842.GF27706@comcast.net>
Tim Walberg <twalberg@comcast.net> writes:
> That does indeed seem to work on first try. Not sure it was
> a particularly critical issue - just unexpected.
I didn't think it is particularly critical, either, and that is why I said
it has been like this for eons at least since v1.6.0.
And it turns out that this was pretty much from day one of name-rev at
bd321bc (Add git-name-rev, 2005-10-26).
^ permalink raw reply
* Re: input director not compatible with git right-click
From: Sitaram Chamarty @ 2011-11-16 4:52 UTC (permalink / raw)
To: Carlos Martín Nieto, Sitaram Chamarty, Eric, git
In-Reply-To: <20111115173843.GB5453@centaur.lab.cmartin.tk>
On Tue, Nov 15, 2011 at 11:08 PM, Carlos Martín Nieto <cmn@elego.de> wrote:
> On Tue, Nov 15, 2011 at 09:39:25PM +0530, Sitaram Chamarty wrote:
>> On Mon, Nov 14, 2011 at 8:10 PM, Carlos Martín Nieto <cmn@elego.de> wrote:
>> > On Sun, Nov 13, 2011 at 04:34:26PM +0000, Eric wrote:
>> >> Hi,
>> >>
>> >> New in Git use, I use it do dev on window some administrative script. I use as
>> >> well Input director to share keyboard and mouse on multiple computer.
>> >
>> > Do you mean you're using it on the Windows OS?
>> >
>> >>
>> >> when I right-clicked on an item, it works when input director is disabled. If
>> >
>> > Right-click on what? git doesn't have a graphical interface. If you're
>> > using a graphical front-end to git, you should send them a bug report.
>>
>> git comes with 3 perfectly cromulent graphical programs, and one of
>> them is indispensable.
>
> I guess we have diferent ideas of where "git" ends and other stuff
> starts. gitk, git-gui and what is the last one?
'git gui blame'
^ permalink raw reply
* Re: Git, Parrot, Perl6, Rakudo for G4 MAC
From: Sitaram Chamarty @ 2011-11-16 4:51 UTC (permalink / raw)
To: Jakub Narebski; +Cc: Hilco Wijbenga, Greg, git
In-Reply-To: <m3fwhpmf1f.fsf@localhost.localdomain>
2011/11/15 Jakub Narebski <jnareb@gmail.com>:
> Git requires Perl version 5.8 at least, so you should not have any
> problems here.
One day someone [1] reminded me that git does not require perl. Some
features, like git add -p, require it but git can be built without
perl.
[1] on irc, while discussing my stated requirements for gitolite
^ permalink raw reply
* Re: odd name-rev behavior?
From: Tim Walberg @ 2011-11-16 1:48 UTC (permalink / raw)
To: git, Junio C Hamano
In-Reply-To: <7vlirht1fw.fsf@alter.siamese.dyndns.org>
[-- Attachment #1: Type: text/plain, Size: 1809 bytes --]
That does indeed seem to work on first try. Not sure it was
a particularly critical issue - just unexpected. For what I
was using it for it was simple to work around. But thanks
for the quick fix!
tw
On 11/15/2011 15:23 -0800, Junio C Hamano wrote:
>> Junio C Hamano <gitster@pobox.com> writes:
>>
>> > Tim Walberg <twalberg@comcast.net> writes:
>> >
>> >> Never noticed this before - is this expected? It doesn't seem to
>> >> match documentation, in any case...
>> >>
>> >> Basically, 'git name-rev --all' lists a lot of lines that are
>> >> marked as "undefined", and most, if not all, of the objects
>> >> represented are trees, not commits... I wouldn't have expected
>> >> name-rev to follow the link from a commit to a tree and try to
>> >> process that result...
>> >
>> > I wouldn't either, but this does not look like a recent breakage. v1.6.0
>> > seems to show the same broken behaviour.
>>
>> And this one-liner should be sufficient (untested).
>>
>> builtin/name-rev.c | 2 +-
>> 1 files changed, 1 insertions(+), 1 deletions(-)
>>
>> diff --git a/builtin/name-rev.c b/builtin/name-rev.c
>> index 7864056..1b37458 100644
>> --- a/builtin/name-rev.c
>> +++ b/builtin/name-rev.c
>> @@ -291,7 +291,7 @@ int cmd_name_rev(int argc, const char **argv, const char *prefix)
>> max = get_max_object_index();
>> for (i = 0; i < max; i++) {
>> struct object *obj = get_indexed_object(i);
>> - if (!obj)
>> + if (!obj || obj->type != OBJ_COMMIT)
>> continue;
>> show_name(obj, NULL,
>> always, allow_undefined, data.name_only);
End of included message
--
+----------------------+
| Tim Walberg |
| 830 Carriage Dr. |
| Algonquin, IL 60102 |
| twalberg@comcast.net |
+----------------------+
[-- Attachment #2: Type: application/pgp-signature, Size: 197 bytes --]
^ permalink raw reply
* Re: [PATCH] revert: prettify fatal messages
From: Junio C Hamano @ 2011-11-16 1:05 UTC (permalink / raw)
To: Ramkumar Ramachandra; +Cc: Git List, Jonathan Nieder
In-Reply-To: <1321349492-5653-1-git-send-email-artagnon@gmail.com>
Ramkumar Ramachandra <artagnon@gmail.com> writes:
> Candidate for 'maint'?
Too minor to matter when 'master' is already at -rc2.
Thanks.
^ permalink raw reply
* Re: [PATCH 2/2] archive: limit ourselves during remote requests
From: Junio C Hamano @ 2011-11-16 0:03 UTC (permalink / raw)
To: Jeff King; +Cc: Erik Faye-Lund, git
In-Reply-To: <20111115214840.GB20624@sigill.intra.peff.net>
Jeff King <peff@peff.net> writes:
> ... just a very stripped-down version of
> git-archive (i.e., it _only_ calls write_archive). Or it could even be
> spelled "git upload-archive --remote-request". But the point is that
> git-archive never needed to worry about security before. We
> shouldn't be polluting it with security code; we should be bypassing it
> going to write_archive directly.
Quite sensible, and a good approach to reroll the series, I would think.
^ permalink raw reply
* Re: [PATCH 0/2] upload-archive security issues
From: Junio C Hamano @ 2011-11-15 23:40 UTC (permalink / raw)
To: Jeff King; +Cc: Erik Faye-Lund, git
In-Reply-To: <20111115222320.GA28646@sigill.intra.peff.net>
Jeff King <peff@peff.net> writes:
>> For the record: I would be fine with c09cd77e simply being reverted
>> for this release, and having a better version applied in the near
>> future. Windows support for upload-archive is not worth the risk of
>> slipping in a remote code execution bug...
>
> I'd be OK with that, too.
Ok, that is easier ;-)
^ permalink raw reply
page: next (older) | prev (newer) | latest
- recent:[subjects (threaded)|topics (new)|topics (active)]
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox