* [PATCH 1/2] fast-export: deletion action first
@ 2017-04-24 23:04 Miguel Torroja
2017-04-24 23:04 ` [PATCH 2/2] fast-export: DIFF_STATUS_RENAMED instead of 'R' Miguel Torroja
0 siblings, 1 reply; 4+ messages in thread
From: Miguel Torroja @ 2017-04-24 23:04 UTC (permalink / raw)
To: git; +Cc: Miguel Torroja
The delete operations of the fast-export output should precede any addition
belonging to the same commit, Addition and deletion with the same name
entry could happen in case of file to directory and viceversa.
The fast-export sorting was added in 060df62 (fast-export: Fix output
order of D/F changes). That change was made in order to fix the case of
directory to file in the same commit, but it broke the reverse case
(File to directory).
Signed-off-by: Miguel Torroja <miguel.torroja@gmail.com>
---
builtin/fast-export.c | 25 +++++++++----------------
1 file changed, 9 insertions(+), 16 deletions(-)
diff --git a/builtin/fast-export.c b/builtin/fast-export.c
index e022063..a3ab7da 100644
--- a/builtin/fast-export.c
+++ b/builtin/fast-export.c
@@ -260,26 +260,19 @@ static void export_blob(const struct object_id *oid)
free(buf);
}
-static int depth_first(const void *a_, const void *b_)
+/*
+ * Compares two diff types to order based on output priorities.
+ */
+static int diff_type_cmp(const void *a_, const void *b_)
{
const struct diff_filepair *a = *((const struct diff_filepair **)a_);
const struct diff_filepair *b = *((const struct diff_filepair **)b_);
- const char *name_a, *name_b;
- int len_a, len_b, len;
int cmp;
- name_a = a->one ? a->one->path : a->two->path;
- name_b = b->one ? b->one->path : b->two->path;
-
- len_a = strlen(name_a);
- len_b = strlen(name_b);
- len = (len_a < len_b) ? len_a : len_b;
-
- /* strcmp will sort 'd' before 'd/e', we want 'd/e' before 'd' */
- cmp = memcmp(name_a, name_b, len);
- if (cmp)
- return cmp;
- cmp = len_b - len_a;
+ /*
+ * Move Delete entries first so that an addition is always reported after
+ */
+ cmp = (b->status == DIFF_STATUS_DELETED) - (a->status == DIFF_STATUS_DELETED);
if (cmp)
return cmp;
/*
@@ -347,7 +340,7 @@ static void show_filemodify(struct diff_queue_struct *q,
* Handle files below a directory first, in case they are all deleted
* and the directory changes to a file or symlink.
*/
- QSORT(q->queue, q->nr, depth_first);
+ QSORT(q->queue, q->nr, diff_type_cmp);
for (i = 0; i < q->nr; i++) {
struct diff_filespec *ospec = q->queue[i]->one;
--
2.1.4
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH 2/2] fast-export: DIFF_STATUS_RENAMED instead of 'R'
2017-04-24 23:04 [PATCH 1/2] fast-export: deletion action first Miguel Torroja
@ 2017-04-24 23:04 ` Miguel Torroja
0 siblings, 0 replies; 4+ messages in thread
From: Miguel Torroja @ 2017-04-24 23:04 UTC (permalink / raw)
To: git; +Cc: Miguel Torroja
Minor change to be consistent with the rest of the fast-export code.
DIFF_STATUS_RENAMED is defined as 'R'.
Signed-off-by: Miguel Torroja <miguel.torroja@gmail.com>
---
builtin/fast-export.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/builtin/fast-export.c b/builtin/fast-export.c
index a3ab7da..4d39324 100644
--- a/builtin/fast-export.c
+++ b/builtin/fast-export.c
@@ -280,7 +280,7 @@ static int diff_type_cmp(const void *a_, const void *b_)
* appear in the output before it is renamed (e.g., when a file
* was copied and renamed in the same commit).
*/
- return (a->status == 'R') - (b->status == 'R');
+ return (a->status == DIFF_STATUS_RENAMED) - (b->status == DIFF_STATUS_RENAMED);
}
static void print_path_1(const char *path)
--
2.1.4
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH 2/2] fast-export: DIFF_STATUS_RENAMED instead of 'R'
2017-04-25 0:04 [PATCH 1/2] fast-export: deletion action first Miguel Torroja
@ 2017-04-25 0:04 ` Miguel Torroja
0 siblings, 0 replies; 4+ messages in thread
From: Miguel Torroja @ 2017-04-25 0:04 UTC (permalink / raw)
To: git; +Cc: Miguel Torroja
Minor change to be consistent with the rest of the fast-export code.
DIFF_STATUS_RENAMED is defined as 'R'.
Signed-off-by: Miguel Torroja <miguel.torroja@gmail.com>
---
builtin/fast-export.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/builtin/fast-export.c b/builtin/fast-export.c
index a3ab7da..4d39324 100644
--- a/builtin/fast-export.c
+++ b/builtin/fast-export.c
@@ -280,7 +280,7 @@ static int diff_type_cmp(const void *a_, const void *b_)
* appear in the output before it is renamed (e.g., when a file
* was copied and renamed in the same commit).
*/
- return (a->status == 'R') - (b->status == 'R');
+ return (a->status == DIFF_STATUS_RENAMED) - (b->status == DIFF_STATUS_RENAMED);
}
static void print_path_1(const char *path)
--
2.1.4
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH 2/2] fast-export: DIFF_STATUS_RENAMED instead of 'R'
2017-04-25 0:12 [PATCH 1/2] fast-export: deletion action first Miguel Torroja
@ 2017-04-25 0:12 ` Miguel Torroja
0 siblings, 0 replies; 4+ messages in thread
From: Miguel Torroja @ 2017-04-25 0:12 UTC (permalink / raw)
To: git; +Cc: Miguel Torroja
Minor change to be consistent with the rest of the fast-export code.
DIFF_STATUS_RENAMED is defined as 'R'.
Signed-off-by: Miguel Torroja <miguel.torroja@gmail.com>
---
builtin/fast-export.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/builtin/fast-export.c b/builtin/fast-export.c
index a3ab7da..4d39324 100644
--- a/builtin/fast-export.c
+++ b/builtin/fast-export.c
@@ -280,7 +280,7 @@ static int diff_type_cmp(const void *a_, const void *b_)
* appear in the output before it is renamed (e.g., when a file
* was copied and renamed in the same commit).
*/
- return (a->status == 'R') - (b->status == 'R');
+ return (a->status == DIFF_STATUS_RENAMED) - (b->status == DIFF_STATUS_RENAMED);
}
static void print_path_1(const char *path)
--
2.1.4
^ permalink raw reply related [flat|nested] 4+ messages in thread
end of thread, other threads:[~2017-04-25 0:12 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-04-24 23:04 [PATCH 1/2] fast-export: deletion action first Miguel Torroja
2017-04-24 23:04 ` [PATCH 2/2] fast-export: DIFF_STATUS_RENAMED instead of 'R' Miguel Torroja
-- strict thread matches above, loose matches on Subject: below --
2017-04-25 0:04 [PATCH 1/2] fast-export: deletion action first Miguel Torroja
2017-04-25 0:04 ` [PATCH 2/2] fast-export: DIFF_STATUS_RENAMED instead of 'R' Miguel Torroja
2017-04-25 0:12 [PATCH 1/2] fast-export: deletion action first Miguel Torroja
2017-04-25 0:12 ` [PATCH 2/2] fast-export: DIFF_STATUS_RENAMED instead of 'R' Miguel Torroja
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).