diff options
author | Michael Halstead <michael@yoctoproject.org> | 2012-11-15 05:41:01 (JST) |
---|---|---|
committer | Jason A. Donenfeld <Jason@zx2c4.com> | 2012-11-15 08:56:20 (JST) |
commit | 62a40c78fed772e795eca8d4e7d6f6ead4d9a125 (patch) | |
tree | 03d81c7b21c66594d7380f118fdf2711a248bf6d /ui-diff.c | |
parent | 633a66c8226286d4559e72f0dce23586d617faff (diff) | |
download | cgit-62a40c78fed772e795eca8d4e7d6f6ead4d9a125.zip cgit-62a40c78fed772e795eca8d4e7d6f6ead4d9a125.tar.gz |
Format git diff headers correctly when adding or removing files.
Copying the output of cgit and using it in patches now works when adding
files to or removing files from the repository. This is helpful for people
who use cgit in their patch workflow.
Diffstat (limited to 'ui-diff.c')
-rw-r--r-- | ui-diff.c | 17 |
1 files changed, 10 insertions, 7 deletions
@@ -229,11 +229,6 @@ static void header(unsigned char *sha1, char *path1, int mode1, | |||
229 | html(" b/"); | 229 | html(" b/"); |
230 | html_txt(path2); | 230 | html_txt(path2); |
231 | 231 | ||
232 | if (is_null_sha1(sha1)) | ||
233 | path1 = "dev/null"; | ||
234 | if (is_null_sha1(sha2)) | ||
235 | path2 = "dev/null"; | ||
236 | |||
237 | if (mode1 == 0) | 232 | if (mode1 == 0) |
238 | htmlf("<br/>new file mode %.6o", mode2); | 233 | htmlf("<br/>new file mode %.6o", mode2); |
239 | 234 | ||
@@ -251,13 +246,21 @@ static void header(unsigned char *sha1, char *path1, int mode1, | |||
251 | if (mode2 != mode1) | 246 | if (mode2 != mode1) |
252 | htmlf("..%.6o", mode2); | 247 | htmlf("..%.6o", mode2); |
253 | } | 248 | } |
254 | html("<br/>--- a/"); | 249 | if (is_null_sha1(sha1)) { |
250 | path1 = "dev/null"; | ||
251 | html("<br/>--- /"); | ||
252 | } else | ||
253 | html("<br/>--- a/"); | ||
255 | if (mode1 != 0) | 254 | if (mode1 != 0) |
256 | cgit_tree_link(path1, NULL, NULL, ctx.qry.head, | 255 | cgit_tree_link(path1, NULL, NULL, ctx.qry.head, |
257 | sha1_to_hex(old_rev_sha1), path1); | 256 | sha1_to_hex(old_rev_sha1), path1); |
258 | else | 257 | else |
259 | html_txt(path1); | 258 | html_txt(path1); |
260 | html("<br/>+++ b/"); | 259 | if (is_null_sha1(sha2)) { |
260 | path2 = "dev/null"; | ||
261 | html("<br/>+++ /"); | ||
262 | } else | ||
263 | html("<br/>+++ b/"); | ||
261 | if (mode2 != 0) | 264 | if (mode2 != 0) |
262 | cgit_tree_link(path2, NULL, NULL, ctx.qry.head, | 265 | cgit_tree_link(path2, NULL, NULL, ctx.qry.head, |
263 | sha1_to_hex(new_rev_sha1), path2); | 266 | sha1_to_hex(new_rev_sha1), path2); |