From ce1d8ee5bd88cc05c6e0cdee4517bb1ab8fb6100 Mon Sep 17 00:00:00 2001 From: Ben Wiederhake Date: Tue, 20 Jun 2017 10:57:28 +0200 Subject: Add .gitignore --- .gitignore | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..749f85d --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +/hadori +/hadori.o +/hadori.1 -- cgit v1.2.3 From 07d402e83fd6b58d53825441169503cc92fd71d6 Mon Sep 17 00:00:00 2001 From: Ben Wiederhake Date: Tue, 20 Jun 2017 10:58:54 +0200 Subject: Clang lints ('static' and typing) --- hadori.C | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/hadori.C b/hadori.C index b1f0e5f..f5aebda 100644 --- a/hadori.C +++ b/hadori.C @@ -40,8 +40,8 @@ namespace po = boost::program_options; #include "version.h" -po::variables_map config; -std::ostream debug(std::clog.rdbuf()), verbose(std::clog.rdbuf()), error(std::clog.rdbuf()); +static po::variables_map config; +static std::ostream debug(std::clog.rdbuf()), verbose(std::clog.rdbuf()), error(std::clog.rdbuf()); struct inode { std::string const filename; @@ -59,7 +59,7 @@ inline bool compare (inode const & l, inode const & r) { rf.read(rbuffer, sizeof(rbuffer)); if (lf.gcount() != rf.gcount()) return false; - if (memcmp(lbuffer, rbuffer, lf.gcount())) + if (memcmp(lbuffer, rbuffer, static_cast(lf.gcount()))) return false; } return true; @@ -70,7 +70,7 @@ inline std::ostream& operator<< (std::ostream& os, inode const & i) { return os; } -void do_link (inode const & i, std::string const & other) { +static void do_link (inode const & i, std::string const & other) { if (!link(i.filename.c_str(), other.c_str())) { error << "linking " << i << " to " << other << " succeeded before unlinking (race condition)" << std::endl; exit(EX_UNAVAILABLE); @@ -92,7 +92,7 @@ void do_link (inode const & i, std::string const & other) { } } -void handle_file(std::string const & path, struct stat const & s) { +static void handle_file (std::string const & path, struct stat const & s) { static std::unordered_map kept; static std::unordered_map to_link; static std::unordered_multimap sizes; @@ -138,7 +138,7 @@ void handle_file(std::string const & path, struct stat const & s) { sizes.insert({s.st_size, s.st_ino}); } -void recurse (std::string const & dir, dev_t const dev) { +static void recurse (std::string const & dir, dev_t const dev) { DIR* D; struct dirent *d; struct stat s; @@ -179,7 +179,7 @@ void recurse (std::string const & dir, dev_t const dev) { } } -void recurse_start (std::string const & dir) { +static void recurse_start (std::string const & dir) { struct stat s; if (lstat(dir.c_str(), &s)) { -- cgit v1.2.3 From 2cad5033359975238cbb95824595b638892bc039 Mon Sep 17 00:00:00 2001 From: Timo Weingärtner Date: Sat, 27 Oct 2018 21:37:40 +0200 Subject: move dry-run checking into do_link --- hadori.C | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/hadori.C b/hadori.C index f5aebda..4465ef3 100644 --- a/hadori.C +++ b/hadori.C @@ -71,6 +71,8 @@ inline std::ostream& operator<< (std::ostream& os, inode const & i) { } static void do_link (inode const & i, std::string const & other) { + if (config.count("dry-run")) + return; if (!link(i.filename.c_str(), other.c_str())) { error << "linking " << i << " to " << other << " succeeded before unlinking (race condition)" << std::endl; exit(EX_UNAVAILABLE); @@ -129,8 +131,7 @@ static void handle_file (std::string const & path, struct stat const & s) { verbose << "linking " << candidate << " to " << path << std::endl; if (s.st_nlink > 1) to_link.insert({s.st_ino, it.second}); - if (not config.count("dry-run")) - do_link(candidate, path); + do_link(candidate, path); return; } debug << "we keep " << f << std::endl; -- cgit v1.2.3 From 36dbc5d061b39b22f2620ac0e0a137ea05dbad33 Mon Sep 17 00:00:00 2001 From: Timo Weingärtner Date: Wed, 13 Jan 2021 23:53:07 +0100 Subject: improve man page generation with help2man --- Makefile | 4 ++-- hadori.C | 11 +++++++---- hadori.help2man | 13 +++++++++++++ 3 files changed, 22 insertions(+), 6 deletions(-) create mode 100644 hadori.help2man diff --git a/Makefile b/Makefile index e8f40f6..959bb81 100644 --- a/Makefile +++ b/Makefile @@ -22,8 +22,8 @@ CPPFLAGS+=-D_FILE_OFFSET_BITS=64 all: hadori.1 -hadori.1: hadori - help2man -n $< -o $@ -N ./$< +%.1: %.help2man % + help2man -i $< -o $@ -N -L C.UTF-8 $(*D)/$(*F) hadori: hadori.o hadori.o: hadori.C version.h diff --git a/hadori.C b/hadori.C index 4465ef3..42a93df 100644 --- a/hadori.C +++ b/hadori.C @@ -202,7 +202,7 @@ static void recurse_start (std::string const & dir) { } int main (int const argc, char const * const * const argv) { - po::options_description opts("OPTIONS"); + po::options_description opts("Options"); opts.add_options() ("help,h", "print this help message") ("version,V", "print version information") @@ -224,13 +224,16 @@ int main (int const argc, char const * const * const argv) { po::notify(config); if (config.count("help")) { - std::cout << "Invocation: hadori [ OPTIONS ] [ ARGUMENTS ]" << std::endl; - std::cout << opts << std::endl; + std::cout << "Usage: hadori [ OPTIONS ] [ ARGUMENTS ]\n"; + std::cout << opts; return EX_OK; } if (config.count("version")) { - std::cout << HADORI_VERSION << std::endl; + std::cout << HADORI_VERSION "\n"; + std::cout << "Written by Timo Weingärtner.\n"; + std::cout << "Report bugs to the Debian BTS at https://bugs.debian.org/\n"; + std::cout << "or by mail to timo@tiwe.de.\n"; return EX_OK; } diff --git a/hadori.help2man b/hadori.help2man new file mode 100644 index 0000000..859dd2f --- /dev/null +++ b/hadori.help2man @@ -0,0 +1,13 @@ +# roff markup for the list generated using "pandoc -t man" and pasted here +[NAME] +hadori \- hardlink identical files +[DESCRIPTION] +This might look like yet another hardlinking tool, but it is the only one which only memorizes one filename per inode. That results in less memory consumption and faster execution compared to its +alternatives. Therefore (and because all the other names are already taken) it's called "HArdlinking DOne RIght". + +Advantages over other hardlinking tools: +.IP \[bu] 2 +predictability: arguments are scanned in order, each first version is +kept +.IP \[bu] 2 +much lower CPU and memory consumption -- cgit v1.2.3 From 3d3fe99d72668bc1d0a4e16d9bc3a5b1d86c4935 Mon Sep 17 00:00:00 2001 From: Timo Weingärtner Date: Wed, 13 Jan 2021 23:58:41 +0100 Subject: release 1.1 --- changelog | 30 ++++++++++++++++++++++++++++++ version.h | 2 +- 2 files changed, 31 insertions(+), 1 deletion(-) diff --git a/changelog b/changelog index c2e8b94..9dc4dd9 100644 --- a/changelog +++ b/changelog @@ -1,3 +1,33 @@ +commit 36dbc5d061b39b22f2620ac0e0a137ea05dbad33 +Author: Timo Weingärtner +Date: 2021-01-13 23:53:07 +0100 + + improve man page generation with help2man + +commit 2cad5033359975238cbb95824595b638892bc039 +Author: Timo Weingärtner +Date: 2018-10-27 21:37:40 +0200 + + move dry-run checking into do_link + +commit 07d402e83fd6b58d53825441169503cc92fd71d6 +Author: Ben Wiederhake +Date: 2017-06-20 10:58:54 +0200 + + Clang lints ('static' and typing) + +commit ce1d8ee5bd88cc05c6e0cdee4517bb1ab8fb6100 +Author: Ben Wiederhake +Date: 2017-06-20 10:57:28 +0200 + + Add .gitignore + +commit a987b5383931dd4735a3f7e2261e9a809543b22a (tag: 1.0) +Author: Timo Weingärtner +Date: 2017-04-30 12:45:05 +0200 + + release 1.0 + commit 75293a34994df27b84ee30d94b8db625b0ca40ea Author: Timo Weingärtner Date: 2014-11-23 01:06:29 +0100 diff --git a/version.h b/version.h index 1805f4d..5fb0b6a 100644 --- a/version.h +++ b/version.h @@ -1 +1 @@ -#define HADORI_VERSION "hadori 0.2" +#define HADORI_VERSION "hadori 1.1" -- cgit v1.2.3