xaizek / zograscope (License: AGPLv3 only) (since 2018-12-07)
Mainly a syntax-aware diff that also provides a number of additional tools.
Commit a1d50fcd637d6c0fe4d45d8c50c1916cf1f1b41b

Extract diff's git fallback logic into a function
Author: xaizek
Author date (UTC): 2022-05-15 21:54
Committer name: xaizek
Committer date (UTC): 2022-05-15 21:54
Parent(s): 26918dc4dc7fd6f6801f78489fce007e6c5607ac
Signing key: 99DC5E4DB05F6BE2
Tree: 16909f7409fe89ad5c2d27bc5b2cff5528921b42
File Lines added Lines deleted
tools/diff/diff.cpp 15 8
File tools/diff/diff.cpp changed (mode: 100644) (index 0b9b2d8..2d804b8)
... ... struct Args : CommonArgs
47 47 static boost::program_options::options_description getLocalOpts(); static boost::program_options::options_description getLocalOpts();
48 48 static Args parseLocalArgs(const Environment &env); static Args parseLocalArgs(const Environment &env);
49 49 static int run(Environment &env, const Args &args); static int run(Environment &env, const Args &args);
50 static int gitFallback(const Args &args);
50 51
51 52 int int
52 53 main(int argc, char *argv[]) main(int argc, char *argv[])
 
... ... main(int argc, char *argv[])
83 84 } }
84 85
85 86 if (result != EXIT_SUCCESS && args.gitDiff) { if (result != EXIT_SUCCESS && args.gitDiff) {
86 if (args.pos[5] == std::string(40U, '0')) {
87 execlp("git", "git", "diff", "--no-ext-diff", args.pos[2].c_str(),
88 "--", args.pos[0].c_str(), static_cast<char *>(nullptr));
89 exit(127);
90 }
91 execlp("git", "git", "diff", "--no-ext-diff", args.pos[2].c_str(),
92 args.pos[5].c_str(), "--", static_cast<char *>(nullptr));
93 exit(127);
87 return gitFallback(args);
94 88 } }
95 89
96 90 return result; return result;
 
... ... run(Environment &env, const Args &args)
198 192
199 193 return EXIT_SUCCESS; return EXIT_SUCCESS;
200 194 } }
195
196 static int
197 gitFallback(const Args &args)
198 {
199 if (args.pos[5] == std::string(40U, '0')) {
200 execlp("git", "git", "diff", "--no-ext-diff", args.pos[2].c_str(),
201 "--", args.pos[0].c_str(), static_cast<char *>(nullptr));
202 return 127;
203 }
204 execlp("git", "git", "diff", "--no-ext-diff", args.pos[2].c_str(),
205 args.pos[5].c_str(), "--", static_cast<char *>(nullptr));
206 return 127;
207 }
Hints

Before first commit, do not forget to setup your git environment:
git config --global user.name "your_name_here"
git config --global user.email "your@email_here"

Clone this repository using HTTP(S):
git clone https://code.reversed.top/user/xaizek/zograscope

Clone this repository using ssh (do not forget to upload a key first):
git clone ssh://rocketgit@code.reversed.top/user/xaizek/zograscope

You are allowed to anonymously push to this repository.
This means that your pushed commits will automatically be transformed into a pull request:
... clone the repository ...
... make some changes and some commits ...
git push origin master