From: Junio C Hamano <gitster@pobox.com>
To: git@vger.kernel.org
Subject: [PATCH v3 16/18] rerere: call conflict-ids IDs
Date: Fri, 17 Jul 2015 15:24:38 -0700 [thread overview]
Message-ID: <1437171880-21590-17-git-send-email-gitster@pobox.com> (raw)
In-Reply-To: <1437171880-21590-1-git-send-email-gitster@pobox.com>
Most places we call conflict IDs "name" and some others we call them
"hex"; update all of them to "id".
Signed-off-by: Junio C Hamano <gitster@pobox.com>
---
builtin/rerere.c | 4 +--
rerere.c | 76 ++++++++++++++++++++++++++++----------------------------
rerere.h | 2 +-
3 files changed, 41 insertions(+), 41 deletions(-)
diff --git a/builtin/rerere.c b/builtin/rerere.c
index 98eb8c5..81730bb 100644
--- a/builtin/rerere.c
+++ b/builtin/rerere.c
@@ -103,8 +103,8 @@ int cmd_rerere(int argc, const char **argv, const char *prefix)
} else if (!strcmp(argv[0], "diff"))
for (i = 0; i < merge_rr.nr; i++) {
const char *path = merge_rr.items[i].string;
- const char *name = (const char *)merge_rr.items[i].util;
- diff_two(rerere_path(name, "preimage"), path, path, path);
+ const char *id = (const char *)merge_rr.items[i].util;
+ diff_two(rerere_path(id, "preimage"), path, path, path);
}
else
usage_with_options(rerere_usage, options);
diff --git a/rerere.c b/rerere.c
index 30bdfeb..e68469a 100644
--- a/rerere.c
+++ b/rerere.c
@@ -22,15 +22,15 @@ static int rerere_autoupdate;
static char *merge_rr_path;
-const char *rerere_path(const char *hex, const char *file)
+const char *rerere_path(const char *id, const char *file)
{
- return git_path("rr-cache/%s/%s", hex, file);
+ return git_path("rr-cache/%s/%s", id, file);
}
-static int has_rerere_resolution(const char *hex)
+static int has_rerere_resolution(const char *id)
{
struct stat st;
- return !stat(rerere_path(hex, "postimage"), &st);
+ return !stat(rerere_path(id, "postimage"), &st);
}
/*
@@ -530,7 +530,7 @@ int rerere_remaining(struct string_list *merge_rr)
}
/*
- * Find the conflict identified by "name"; the change between its
+ * Find the conflict identified by "id"; the change between its
* "preimage" (i.e. a previous contents with conflict markers) and its
* "postimage" (i.e. the corresponding contents with conflicts
* resolved) may apply cleanly to the contents stored in "path", i.e.
@@ -539,7 +539,7 @@ int rerere_remaining(struct string_list *merge_rr)
* Returns 0 for successful replay of recorded resolution, or non-zero
* for failure.
*/
-static int merge(const char *name, const char *path)
+static int merge(const char *id, const char *path)
{
int ret;
mmfile_t cur = {NULL, 0}, base = {NULL, 0}, other = {NULL, 0};
@@ -549,12 +549,12 @@ static int merge(const char *name, const char *path)
* Normalize the conflicts in path and write it out to
* "thisimage" temporary file.
*/
- if (handle_file(path, NULL, rerere_path(name, "thisimage")) < 0)
+ if (handle_file(path, NULL, rerere_path(id, "thisimage")) < 0)
return 1;
- if (read_mmfile(&cur, rerere_path(name, "thisimage")) ||
- read_mmfile(&base, rerere_path(name, "preimage")) ||
- read_mmfile(&other, rerere_path(name, "postimage"))) {
+ if (read_mmfile(&cur, rerere_path(id, "thisimage")) ||
+ read_mmfile(&base, rerere_path(id, "preimage")) ||
+ read_mmfile(&other, rerere_path(id, "postimage"))) {
ret = 1;
goto out;
}
@@ -571,9 +571,9 @@ static int merge(const char *name, const char *path)
* A successful replay of recorded resolution.
* Mark that "postimage" was used to help gc.
*/
- if (utime(rerere_path(name, "postimage"), NULL) < 0)
+ if (utime(rerere_path(id, "postimage"), NULL) < 0)
warning("failed utime() on %s: %s",
- rerere_path(name, "postimage"),
+ rerere_path(id, "postimage"),
strerror(errno));
/* Update "path" with the resolution */
@@ -631,11 +631,11 @@ static void do_rerere_one_path(struct string_list_item *rr_item,
struct string_list *update)
{
const char *path = rr_item->string;
- const char *name = (const char *)rr_item->util;
+ const char *id = (const char *)rr_item->util;
/* Is there a recorded resolution we could attempt to apply? */
- if (has_rerere_resolution(name)) {
- if (merge(name, path))
+ if (has_rerere_resolution(id)) {
+ if (merge(id, path))
return; /* failed to replay */
if (rerere_autoupdate)
@@ -646,7 +646,7 @@ static void do_rerere_one_path(struct string_list_item *rr_item,
path);
} else if (!handle_file(path, NULL, NULL)) {
/* The user has resolved it. */
- copy_file(rerere_path(name, "postimage"), path, 0666);
+ copy_file(rerere_path(id, "postimage"), path, 0666);
fprintf(stderr, "Recorded resolution for '%s'.\n", path);
} else {
return;
@@ -671,7 +671,7 @@ static int do_plain_rerere(struct string_list *rr, int fd)
*/
for (i = 0; i < conflict.nr; i++) {
unsigned char sha1[20];
- char *hex;
+ char *id;
int ret;
const char *path = conflict.items[i].string;
@@ -686,8 +686,8 @@ static int do_plain_rerere(struct string_list *rr, int fd)
ret = handle_file(path, sha1, NULL);
if (ret < 1)
continue;
- hex = xstrdup(sha1_to_hex(sha1));
- string_list_insert(rr, path)->util = hex;
+ id = xstrdup(sha1_to_hex(sha1));
+ string_list_insert(rr, path)->util = id;
/*
* If the directory does not exist, create
@@ -697,7 +697,7 @@ static int do_plain_rerere(struct string_list *rr, int fd)
* NEEDSWORK: make sure "gc" does not remove
* preimage without removing the directory.
*/
- if (mkdir_in_gitdir(git_path("rr-cache/%s", hex)))
+ if (mkdir_in_gitdir(git_path("rr-cache/%s", id)))
continue;
/*
@@ -705,7 +705,7 @@ static int do_plain_rerere(struct string_list *rr, int fd)
* conflict. Ask handle_file() to write the
* normalized contents to the "preimage" file.
*/
- handle_file(path, NULL, rerere_path(hex, "preimage"));
+ handle_file(path, NULL, rerere_path(id, "preimage"));
fprintf(stderr, "Recorded preimage for '%s'\n", path);
}
@@ -779,7 +779,7 @@ int rerere(int flags)
static int rerere_forget_one_path(const char *path, struct string_list *rr)
{
const char *filename;
- char *hex;
+ char *id;
unsigned char sha1[20];
int ret;
struct string_list_item *item;
@@ -793,8 +793,8 @@ static int rerere_forget_one_path(const char *path, struct string_list *rr)
return error("Could not parse conflict hunks in '%s'", path);
/* Nuke the recorded resolution for the conflict */
- hex = xstrdup(sha1_to_hex(sha1));
- filename = rerere_path(hex, "postimage");
+ id = xstrdup(sha1_to_hex(sha1));
+ filename = rerere_path(id, "postimage");
if (unlink(filename))
return (errno == ENOENT
? error("no remembered resolution for %s", path)
@@ -805,7 +805,7 @@ static int rerere_forget_one_path(const char *path, struct string_list *rr)
* conflict in the working tree, run us again to record
* the postimage.
*/
- handle_cache(path, sha1, rerere_path(hex, "preimage"));
+ handle_cache(path, sha1, rerere_path(id, "preimage"));
fprintf(stderr, "Updated preimage for '%s'\n", path);
/*
@@ -814,7 +814,7 @@ static int rerere_forget_one_path(const char *path, struct string_list *rr)
*/
item = string_list_insert(rr, path);
free(item->util);
- item->util = hex;
+ item->util = id;
fprintf(stderr, "Forgot resolution for %s\n", path);
return 0;
}
@@ -850,32 +850,32 @@ int rerere_forget(struct pathspec *pathspec)
/*
* Garbage collection support
*/
-static time_t rerere_created_at(const char *name)
+static time_t rerere_created_at(const char *id)
{
struct stat st;
- return stat(rerere_path(name, "preimage"), &st) ? (time_t) 0 : st.st_mtime;
+ return stat(rerere_path(id, "preimage"), &st) ? (time_t) 0 : st.st_mtime;
}
-static time_t rerere_last_used_at(const char *name)
+static time_t rerere_last_used_at(const char *id)
{
struct stat st;
- return stat(rerere_path(name, "postimage"), &st) ? (time_t) 0 : st.st_mtime;
+ return stat(rerere_path(id, "postimage"), &st) ? (time_t) 0 : st.st_mtime;
}
/*
* Remove the recorded resolution for a given conflict ID
*/
-static void unlink_rr_item(const char *name)
+static void unlink_rr_item(const char *id)
{
- unlink(rerere_path(name, "thisimage"));
- unlink(rerere_path(name, "preimage"));
- unlink(rerere_path(name, "postimage"));
+ unlink(rerere_path(id, "thisimage"));
+ unlink(rerere_path(id, "preimage"));
+ unlink(rerere_path(id, "postimage"));
/*
* NEEDSWORK: what if this rmdir() fails? Wouldn't we then
* assume that we already have preimage recorded in
* do_plain_rerere()?
*/
- rmdir(git_path("rr-cache/%s", name));
+ rmdir(git_path("rr-cache/%s", id));
}
void rerere_gc(struct string_list *rr)
@@ -930,9 +930,9 @@ void rerere_clear(struct string_list *merge_rr)
int i;
for (i = 0; i < merge_rr->nr; i++) {
- const char *name = (const char *)merge_rr->items[i].util;
- if (!has_rerere_resolution(name))
- unlink_rr_item(name);
+ const char *id = (const char *)merge_rr->items[i].util;
+ if (!has_rerere_resolution(id))
+ unlink_rr_item(id);
}
unlink_or_warn(git_path("MERGE_RR"));
}
diff --git a/rerere.h b/rerere.h
index 2956c2e..f998eba 100644
--- a/rerere.h
+++ b/rerere.h
@@ -17,7 +17,7 @@ extern void *RERERE_RESOLVED;
extern int setup_rerere(struct string_list *, int);
extern int rerere(int);
-extern const char *rerere_path(const char *hex, const char *file);
+extern const char *rerere_path(const char *id, const char *file);
extern int rerere_forget(struct pathspec *);
extern int rerere_remaining(struct string_list *);
extern void rerere_clear(struct string_list *);
--
2.5.0-rc2-340-g0cccc16
next prev parent reply other threads:[~2015-07-17 22:25 UTC|newest]
Thread overview: 39+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-07-01 6:04 [PATCH v2 00/13] "rerere" minor clean-up Junio C Hamano
2015-07-01 6:04 ` [PATCH v2 01/13] rerere: fix an off-by-one non-bug Junio C Hamano
2015-07-01 6:04 ` [PATCH v2 02/13] rerere: plug conflict ID leaks Junio C Hamano
2015-07-01 6:04 ` [PATCH v2 03/13] rerere: lift PATH_MAX limitation Junio C Hamano
2015-07-01 6:04 ` [PATCH v2 04/13] rerere: write out each record of MERGE_RR in one go Junio C Hamano
2015-07-01 6:04 ` [PATCH v2 05/13] rerere: report autoupdated paths only after actually updating them Junio C Hamano
2015-07-01 6:04 ` [PATCH v2 06/13] rerere: drop want_sp parameter from is_cmarker() Junio C Hamano
2015-07-01 6:04 ` [PATCH v2 07/13] rerere: stop looping unnecessarily Junio C Hamano
2015-07-01 6:04 ` [PATCH v2 08/13] rerere: explain the rerere I/O abstraction Junio C Hamano
2015-07-01 6:04 ` [PATCH v2 09/13] rerere: explain MERGE_RR management helpers Junio C Hamano
2015-07-01 6:04 ` [PATCH v2 10/13] rerere: explain the primary codepath Junio C Hamano
2015-07-01 6:04 ` [PATCH v2 11/13] rerere: explain "rerere forget" codepath Junio C Hamano
2015-07-01 6:04 ` [PATCH v2 12/13] rerere: explain the remainder Junio C Hamano
2015-07-01 6:04 ` [PATCH v2 13/13] rerere: refactor "replay" part of do_plain_rerere() Junio C Hamano
2015-07-17 22:24 ` [PATCH v3 00/18] "rerere" preparatory clean-up Junio C Hamano
2015-07-17 22:24 ` [PATCH v3 01/18] rerere: fix an off-by-one non-bug Junio C Hamano
2015-07-24 19:46 ` Junio C Hamano
2015-07-17 22:24 ` [PATCH v3 02/18] rerere: plug conflict ID leaks Junio C Hamano
2015-07-17 22:24 ` [PATCH v3 03/18] rerere: lift PATH_MAX limitation Junio C Hamano
2015-07-17 22:24 ` [PATCH v3 04/18] rerere: write out each record of MERGE_RR in one go Junio C Hamano
2015-07-17 22:24 ` [PATCH v3 05/18] rerere: report autoupdated paths only after actually updating them Junio C Hamano
2015-07-17 22:24 ` [PATCH v3 06/18] rerere: drop want_sp parameter from is_cmarker() Junio C Hamano
2015-07-18 8:24 ` Philip Oakley
2015-07-18 8:47 ` Eric Sunshine
2015-07-17 22:24 ` [PATCH v3 07/18] rerere: stop looping unnecessarily Junio C Hamano
2015-07-24 20:06 ` Junio C Hamano
2015-07-17 22:24 ` [PATCH v3 08/18] rerere: explain the rerere I/O abstraction Junio C Hamano
2015-07-24 20:42 ` Junio C Hamano
2015-07-17 22:24 ` [PATCH v3 09/18] rerere: explain MERGE_RR management helpers Junio C Hamano
2015-07-17 22:24 ` [PATCH v3 10/18] rerere: explain the primary codepath Junio C Hamano
2015-07-17 22:24 ` [PATCH v3 11/18] rerere: explain "rerere forget" codepath Junio C Hamano
2015-07-17 22:24 ` [PATCH v3 12/18] rerere: explain the remainder Junio C Hamano
2015-07-17 22:24 ` [PATCH v3 13/18] rerere: refactor "replay" part of do_plain_rerere() Junio C Hamano
2015-07-17 22:24 ` [PATCH v3 14/18] rerere: further de-dent do_plain_rerere() Junio C Hamano
2015-07-17 22:24 ` [PATCH v3 15/18] rerere: further clarify do_rerere_one_path() Junio C Hamano
2015-07-17 22:24 ` Junio C Hamano [this message]
2015-07-17 22:24 ` [PATCH v3 17/18] rerere: use "struct rerere_id" instead of "char *" for conflict ID Junio C Hamano
2015-07-18 8:47 ` Eric Sunshine
2015-07-17 22:24 ` [PATCH v3 18/18] rerere: un-nest merge() further Junio C Hamano
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1437171880-21590-17-git-send-email-gitster@pobox.com \
--to=gitster@pobox.com \
--cc=git@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).